Solved Use FIND to Select multiple words in document

Whitebox / MINE
March 31, 2015 at 04:25:20
Specs: Windows 7, e6850/4GB
I have a word document with multiple model numbers like DOR-9754, DOR-9667, DOR-9331 scattered throughout the document. I would like to be able to select them all, and change the font/size, while leaving all the other words intact. I just want those model numbers to have a distinct font, size, or both.

One way is just to manually highlight every DOR-xxxx word I see on the screen with my mouse, one by one... but that takes so long! Is there a way to use Word 2007's FIND function to have it select all words starting with "DOR-"?

I know that Word can 'Use Wildcards', but I haven't found anything yet that works. I can have Word Find all instances of DOR-... but it will only highlight those letters, not whatever four numbers that follow. I thought maybe having it Find "DOR-*" would work, but apparantly not. using the Special button to have it find and highlight <DOR again also only highlights the three letters, not what comes after them.

See More: Use FIND to Select multiple words in document

March 31, 2015 at 05:05:02
I'm not a Word expert but the FIND function will get you what you want,
but you want the wild card ? so this should work: DOR-????

and if you then combine it with a quick Macro and you should be good to go.

Try this:

Open your document
Select Home Tab
Select Find
Click the More >> Button
Click the Use Wildcard box
In the Find What box enter: DOR-????

( Do not close the Find window )

Next Click the Developer Tab
Click Record Macro
Click OK ( Using the default name of Macro 1)

Back in the Find Window
Click the Find Next button
Click the Home Tab
Select your Font Size

Click the Developer Tab
Click Stop Recording

Close the Find Window
Click the Developer Tab
Click the Macros button
Select Macro 1
Click the Run button

Now every time you click Macro 1 the next DOR-???? string should change font size.

See if that works for you


Report •

March 31, 2015 at 06:45:27
Just as a suggestion, you can also add a Shortcut for your Macro.

One way is to add it to the Quick Access Toolbar:

Click the Microsoft Office Button
Click Word Options.
Click Customize (Left pane)
Under Choose Command From
Click the Arrow and Select Macros

You should see your Macro 1 listed.

Double Click the line with Macro 1
and it should appear in the right hand box
under Customize Quick Access Toolbar
with the default Icon that looks like three connected box's.

To change the Icon,
In the Customize Quick Access Toolbar box
Select the line: Macro 1
The Modify Box should appear at the bottom
Select the Modify Box
Select a New Icon
Click OK
Click OK


Report •

March 31, 2015 at 12:22:04
✔ Best Answer
Taking Mike's fine suggestion one step further, I modified the recorded macro to change all occurrences of DOR-???? with a single click.

This code changes the Font Size to 20 and changes the Font Color to Dark Blue, just to show you that the code can do multiple things to the string.

BTW...if the developer tab is not present on your Ribbon, you will have to add it:

Customize Ribbon
Look in the Right hand pane and check the box next to Developer

Sub DOR_Font()

'Move cursor to beginning of Document
  Selection.HomeKey Unit:=wdStory
'Make sure at least one occurrence of DOR-???? exists
    With Selection.Find
        .Text = "DOR-????"
        .Replacement.Text = ""
        .MatchWildcards = True
    End With
'Move cursor to beginning of Document
  Selection.HomeKey Unit:=wdStory
'Loop through document, changing font size (and color) of each DOR-????
    Do While Selection.Find.Found = True
           Selection.Font.Size = 20
           Selection.Font.ColorIndex = wdDarkBlue
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions

Ask Question