marsy00
09-07-2012, 01:45 PM
I have a requirements document with a number of "tags" in it of the form "GW:xxx"
I'd like to write a macro to number all of these tags in order. So far, I've done this:
With Selection
.HomeKey wdStory
With .Find
Do While .Execute(findText:="GW:", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set rngReqTag = Selection.Range
rngReqTag.MoveEnd (wdWord)
strReqTag = "GW:" & i
rngReqTag.Text = strReqTag
i = i + 1
Loop
End With
End With
The problem with this is that it continuously loops on the first found tag, it never advances to the subsequent tags further down in the document. Can anyone offer any advice?
Also, can someone point me to a good tutorial/overview of vba for word? I've written some macros in excel and I'm familiar with coding in general, but I'm having a hard time getting past the learning curve with the various key words, methods, etc. Googling didnt seem to yield anything too helpful for a high level overview.
Thanks!
I'd like to write a macro to number all of these tags in order. So far, I've done this:
With Selection
.HomeKey wdStory
With .Find
Do While .Execute(findText:="GW:", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set rngReqTag = Selection.Range
rngReqTag.MoveEnd (wdWord)
strReqTag = "GW:" & i
rngReqTag.Text = strReqTag
i = i + 1
Loop
End With
End With
The problem with this is that it continuously loops on the first found tag, it never advances to the subsequent tags further down in the document. Can anyone offer any advice?
Also, can someone point me to a good tutorial/overview of vba for word? I've written some macros in excel and I'm familiar with coding in general, but I'm having a hard time getting past the learning curve with the various key words, methods, etc. Googling didnt seem to yield anything too helpful for a high level overview.
Thanks!