S
supersub15
Hi all,
I amended the macro below to fit our needs and need help finalizing
it.
1. Currently, it only looks for I00A0097. How can I modify it to
introduce wildcards? I want to look for anything that looks like
I00A**** (where each asterisk represents a number).
2. Although I did specify that it looks for selections with the style
"HotSpot", it is modifying any style.
Any help is appreciated.
Thanks
Carlos
****************************************
Sub AddURLHyperlinks()
AddURLHyperlinks2 "I00A0097", "FileIO/I00A0097.htm"
End Sub
*******************************************
Sub AddURLHyperlinks2(Dlink As String, HLink As String)
Dim j As Integer
Selection.HomeKey Unit:=wdStory
Do Until j = True
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("HotSpot")
With Selection.Find
.Text = Dlink
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = False Then
Exit Sub
End If
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:=HLink, SubAddress:="", ScreenTip:=HLink,
TextToDisplay:=""
Loop
End Sub
I amended the macro below to fit our needs and need help finalizing
it.
1. Currently, it only looks for I00A0097. How can I modify it to
introduce wildcards? I want to look for anything that looks like
I00A**** (where each asterisk represents a number).
2. Although I did specify that it looks for selections with the style
"HotSpot", it is modifying any style.
Any help is appreciated.
Thanks
Carlos
****************************************
Sub AddURLHyperlinks()
AddURLHyperlinks2 "I00A0097", "FileIO/I00A0097.htm"
End Sub
*******************************************
Sub AddURLHyperlinks2(Dlink As String, HLink As String)
Dim j As Integer
Selection.HomeKey Unit:=wdStory
Do Until j = True
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("HotSpot")
With Selection.Find
.Text = Dlink
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = False Then
Exit Sub
End If
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:=HLink, SubAddress:="", ScreenTip:=HLink,
TextToDisplay:=""
Loop
End Sub