View Single Post
 
Old 09-21-2020, 07:40 AM
2vbr 2vbr is offline Windows 10 Office 2013
Novice
 
Join Date: Sep 2020
Posts: 4
2vbr is on a distinguished road
Question Recording macro for Find Wildcard

I have a Word document of labels. Each label looks like this:

Example Label:
Quote:
Name1.
Name2
Name3
To change the font size of all the Name1's on the labels, I used FIND to highlight all text before the period. In other words...

1. use FIND
2. Tick USE WILDCARDS
2. Paste ?*.
3. Find In: Main Document

Word highlights all the text before the "." character, and I can manually change the size to what I want.

I figured I could make a button macro for this, so I clicked RECORD MACROS, performed all of the above, and then clicked STOP RECORDING.

Problem is... when I click the macro button, literally nothing happens.

I tried recording the same steps but adding one or two random actions afterwards, like pressing Enter or Space. The Macro recorded the random action, just not the Wildcard Find part.

Here's the recorded macro from VBA:

Code:
Sub Styles()
'
' Styles Macro
'
'
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "?*."
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Font.Size = 32
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "?*."
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
End Sub
Any idea what I'm doing wrong? I recorded a 60sec video of what I did, step by step:

https://i.imgur.com/6xJn6sk.mp4

Please not that I'm absolutely not a power user. My only knowledge of VBA is clicking the "Record Macro" button.
Reply With Quote