Trewert
06-04-2008, 08:07 PM
Any help with a macro I am trying to create would be great as I am a beginner to VBA and currently feeling my way through.
I have managed to create a macro to find each instance of [ ...text... ] throughout a document. However I become stuck if there are brackets within brackets ie. it always finishes at the first instance of ] instead of the one I want.
Is there a way that this can be done.I could have totally gone about this in the wrong way but this is what I have created so far.
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "["
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
I will get myself a book and learn this but in the meantime any help is really appreciated.
Thanks
I have managed to create a macro to find each instance of [ ...text... ] throughout a document. However I become stuck if there are brackets within brackets ie. it always finishes at the first instance of ] instead of the one I want.
Is there a way that this can be done.I could have totally gone about this in the wrong way but this is what I have created so far.
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "["
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
I will get myself a book and learn this but in the meantime any help is really appreciated.
Thanks