VBA

Search and Replace in Windows Macro (vba)

This worked for me:

        With Selection.Find^M
           Selection.Find.ClearFormatting^M
           Selection.Find.Replacement.ClearFormatting^M
        ^M
           .Text = "<^#;"^M
           .Replacement.Text = "<" & Counter & ";"

Loop until end of file in Word macro

In writing some code to loop until the end of the file in a Word macro, there are a couple of approaches:

Do Until ActiveDocument.Bookmarks("\Sel") = _
   ActiveDocument.Bookmarks("\EndOfDoc")
       
   Loop
End Sub

Note, I have had this at least once fail to ever find the end of the file. It just infinite looped one line above an empty line that happened to be at the end.

This method worked for me:

Do
   

Word-VBA Code Samples

JoJo Zawawi has provided us with some great code examples, all in one quick reference place.

Syndicate content