Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Key Macro to Search for Character Format 1

Status
Not open for further replies.

k43

Technical User
Apr 24, 2006
1
US
I have a largish (500 pp.) Word 2002 SP3 text file with un-styled bold headings, and I want to search just the headings.

I know how to do the multi-step process:
Ctrl-F
More
Format
Font
Bold
OK
[enter search text and press Enter]

That is, I want the Find screen to pop up with the bold format already assigned, ready for me to type in my search text.

I tried recording the sequence as a macro, assigned to Ctrl-Alt-B, but I get stuck at the last step -- I can't exit the recorder and get the sequence assigned.

Thanks for your help.
 

Firstly, if you press Ctrl+B when the cursor is in the Find what box, the formatting to look for will switch between "Bold", "Not Bold" and (none) - so that will make it a little easier manually.

To use code, this will give you the basics:
Code:
[blue]Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Dialogs(wdDialogEditFind).Show[/blue]
The Selection.Find object is persistent so, to do it properly, you should explicitly set all Find options (record yourself doing a Find, manually switching everything off, to get some basic code for this); otherwise if the user's last find used wildcards, or was for italics, say, you will find those options still set.

When recording a macro, you must set the shortuct key before the recording starts - or do it afterwards via Tools > Custiomize > Keyboard.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top