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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Square brackets in Word

Status
Not open for further replies.

andyc209

IS-IT--Management
Dec 7, 2004
98
GB
Have been asked to create a short cut key in word so a user can tab through a document straight to where he has inserted square brackets (he uses them to identify where he needs to add text later to a template letter). I have tried to assign short cut keys etc in word but i think this has to be done with a macro in the end. Does anyone know a good place to find an example of this? Thanks in advance
 
Are you trying to find the square brackets as a matched pair, perhaps with some text between them? If so, you could use a wildcard Find, where:
Find = [\[]*[\]]
You could record this as a macro, then assign the macro to a keyboard shortcut. Do note that, if you have an opening bracket somewhere and its closing bracket is missing, the above Find expression is liable to select rather more text than you might expect.

Cheers
Paul Edstein
[MS MVP - Word]
 
sounds great, as a macro noobie have you any good sites i can learn this from?
 
The Find expression has nothing to do with macros, though it can be incorporated into one:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[\[]*[\]]"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchWildcards = True
    .Execute
End With
Application.ScreenUpdating = True
End Sub
The Find expression uses a built-in Word wildcard function. If you want to learn about those, see:
Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top