November 11 Update breaks VBA Selection.Extend

Mamue 0 Reputationspunkte
2025-11-14T17:11:52.7333333+00:00

Hello everyone,

we have a macro project in a template file for generating official documents cleanly and uniformly. It has served us well for many many years. One part of the project is the replacement of custom variables. The project uses multiple defined custom variables as well as allows users to create their own. These variables are prefixed and postfixed with a hash/pound sign # to identify and replace (.e.g with values read from an ini file, e.g. data retreived from an LDAP source like ActiveDirectory.

Since the november 11 update, the Selection.Extend breaks on second and every subsequent run. Variables are in the form of e.g. #VTITLE#, which when resolved would replace it with Dr. if applicable. (mqa_setup_1, mqa_success_1).

We use the following code to find the next installment of a variable and replace it (:

Sub s_eingaben_erfragen()
    On Error GoTo Hell
	Dim i As Integer
	Dim StartPos As Long
	
	StartPos = 0
	Selection.HomeKey unit:=wdStory
	Do
		noch_etwas_da = False
		Selection.start = StartPos
	
		With Selection.Find
			.ClearFormatting
			.text = "#"
			.Forward = True
			.Wrap = wdFindContinue
			.Format = False
			.Execute Forward:=True
		End With
	
		If Selection.Find.Found = True Then
			StartPos = Selection.start
	
		
			If StartPos > 2 Then                 
				StartPos = StartPos - 2        ' performance performance gains
			End If                              
	
			noch_etwas_da = True
	
		
			If Selection.Find.text = "#" Then ' set breakpoint here
				Selection.Extend ("#")
				S_Select_Anweisungen             ' Set true or false in p_anweisung, if valid custom command
			End If
	
		
			If P_anweisung = False Then          ' if not resolvable, thus no custom commando
				Selection.Collapse direction:=wdCollapseStart
				Selection.Expand unit:=wdCharacter
				Selection.TypeText "~*~"         ' # will be replaced with ^~^
			End If
		End If
	
	Loop While noch_etwas_da = True
	
	Selection.HomeKey unit:=wdStory              '~*~ wieder zurücksetzen
	Dim ReplErg As Boolean
	ReplErg = True
	Do While ReplErg
		ReplErg = Selection.Find.Execute("~*~", , , , , , , , , "#")
		Selection.Collapse direction:=wdCollapseEnd
	Loop 
	
Exit Sub
	Hell:         PS_Fehlerbehandlung ErrNr:=Err.Number, ErrSource:=Err.Source, ErrDesc:=Err.Description
End Sub

Now in detail:

With Selection.Find
        .ClearFormatting
        .text = "#"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .Execute Forward:=True
    End With

will go and select the next hash, identifiable by halting at the mentioned breakpoint (mqa_1). If we go past

Selection.Extend ("#")

then the entire variable will be selected, including the hashes => #VBA# (mqa_2). The replacement action happens smoothly. When we enter the loop a second time for the second variable the block above still identifies correctly the hash sign (mqa_3), but when we enter into the Selection.Extend it shifts one character away and now only targets BSGCO# (mqa_5) instead of #VBSGO#, which breaks our entire application, since it fails to resolve and runs into an infinite loop of adding ~*~ into the variable position (mqa_fail_1).

Does anybody have tips how to resolve this issue? This absolutely breaks our agencies workflows top to bottom. It definitely is the november patch, once uninstalled everything works smoothly again. We are helpful for any advice you can give us. Thank you and kind regards

Mamue

mqa

Microsoft 365 und Office | Entwicklung | JavaScript-API für Office
0 Kommentare Keine Kommentare
{zählen} Stimmen

Vom Moderator empfohlene Antwort
  1. Mamue 0 Reputationspunkte
    2025-11-17T16:41:46.8933333+00:00

    We have found a solution for the problem by changing our code to mitigate the damage the patch has caused.

    If Selection.Find.text = "#" Then
                    Selection.Extend ("#")
                    If InStr(1, Selection.text, "#") <> 1 Then
                        ' Set highlight of variable# back to #variable#
                        ' In some cases the highlight happens correctly
                        ' Checking with InStr if the first element is a #
                        ' If that is the case Selection.Start will not be lowered                    
    
                        Selection.start = Selection.start - 1
                    End If
                    
                    S_Select_Anweisungen             
                End If
    '....
    
    0 Kommentare Keine Kommentare

5 zusätzliche Antworten

Sortieren nach: Hilfsbereiteste
  1. John DeV 153.5K Reputationspunkte Unabhängiger Berater
    2025-11-14T20:14:06.2266667+00:00

    Hallo, guten Tag!

    Ich empfehle, das Problem über die Feedback-Hub-App zu melden, um Microsoft zu benachrichtigen.

    https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332

    Versuchen Sie bitte, die Updates nach der Deinstallation für 1-2 Wochen zu pausieren, um eine erneute Installation des problematischen Updates zu vermeiden.

    https://support.microsoft.com/windows/pause-updates-in-windows-643e9ea7-3cf6-7da6-a25c-95d4f7f099fe

    Ich freue mich auf Ihr Update und bin bereit, mit Ihnen zusammenzuarbeiten, bis wir das Problem gelöst haben. Halten Sie mich auf dem Laufenden, indem Sie unten auf "Kommentar hinzufügen" klicken.


  2. Thomas L 141.4K Reputationspunkte Freiwilliger Moderator
    2025-11-15T13:40:13.03+00:00

    Hallo,

    vielen Dank für deine Anfrage.

    Stelle Anfragen im deutschsprachigen Forum in deutscher Sprache ein.

    Beachte unter https://learn.microsoft.com/de-de/office/vba/articles/feedback-support die bereitgestellten Informationen, um Unterstützung durch Microsoft zu erhalten.

    Ich freue mich auf deine Rückmeldung.


  3. John DeV 153.5K Reputationspunkte Unabhängiger Berater
    2025-11-16T00:18:39.4933333+00:00

    Es scheint, dass ein Moderator Ihnen eine geeignete Möglichkeit gegeben hat, Ihr Feedback zu dem Thema einzureichen.

    Bleibt gesund und habt einen schönen Tag.

    0 Kommentare Keine Kommentare

  4. Thomas L 141.4K Reputationspunkte Freiwilliger Moderator
    2025-11-16T14:28:19.6566667+00:00

    Hallo,

    vielen Dank für deine Nachricht.

    Stelle deine Frage im englischsprachigen Forum https://learn.microsoft.com/en-us/answers/tags/255/m365-office-development-routing-javascript-api ein.

    Anschließend stelle den Link auf deine dort eingestellte Frage hier ein.

    Ich freue mich auf deine Rückmeldung.

    0 Kommentare Keine Kommentare

Deine Antwort

Antworten können vom Frageautor als 'Akzeptiert' und von den Moderatoren als 'Empfohlen' markiert werden, was den Nutzern hilft, die Lösung des Problems des Autors zu erkennen.