A
Alice
I am advanced in Word, but new to using VBA, having watched Steph Krieger's
Webcast and read a few of your MVP articles on editing macros in VBA. I am
using Word 2003 and am having trouble with the Dim "MyText" As _____ command
in order to do the For Each.....Next command. I don't know what to define
the MyText as. The macro finds the text "Matt.", then a Hyperlink to a
spcific Bookmark in the active document is inserted. There are several
hundred instances of "Matt." in my document. If I could get help with this
step, then I will be able to create macros for the 27 other Bookmarks in my
document!
Here is my initial macro (edited) and it does work:
Option Explicit
Sub MattB()
'
' MattB Macro
' Bookmark to Matthew in TOC
'
With Selection.Find
.ClearFormatting
.Style = ActiveDocument.Styles( _
"Style Body TextBT + Bold Char")
.Text = "Matt."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", _
SubAddress:="Matthew", ScreenTip:="", TextToDisplay:="Matt."
End Sub
Webcast and read a few of your MVP articles on editing macros in VBA. I am
using Word 2003 and am having trouble with the Dim "MyText" As _____ command
in order to do the For Each.....Next command. I don't know what to define
the MyText as. The macro finds the text "Matt.", then a Hyperlink to a
spcific Bookmark in the active document is inserted. There are several
hundred instances of "Matt." in my document. If I could get help with this
step, then I will be able to create macros for the 27 other Bookmarks in my
document!
Here is my initial macro (edited) and it does work:
Option Explicit
Sub MattB()
'
' MattB Macro
' Bookmark to Matthew in TOC
'
With Selection.Find
.ClearFormatting
.Style = ActiveDocument.Styles( _
"Style Body TextBT + Bold Char")
.Text = "Matt."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", _
SubAddress:="Matthew", ScreenTip:="", TextToDisplay:="Matt."
End Sub