Macro to number not working

this macro is supposed to change every @ into a number but it's not doing it.  I can't figure out what's wrong.

 Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("List Number")
    With Selection.Find
        .Text = "@"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With

Answer
Answer

Change .MatchWildcards = True to .MatchWildcards = False.

The @ symbol is a special character in wildcard searches, which is why the macro isn't finding actual @ characters in the document. You could make it work as a wildcard search by changing the .Text string to "\@", but there's no reason to use wildcards here.

_____________________________
https://jay-freedman.info

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 40 Applies to: