R
Richard
I need to update a macro that finds the first filename with a hyperlink (to
that file) so that the macro makes this replacement for all filenames in the
document.
Note: all my filnames begin with "\\ERD", are followed with a "|", and are
preceeded with "_"
Sub AddHyperlinks2Docs()
Dim myRange As Range
Dim i As Long
Dim y As Long
Dim oHpl As Hyperlink
Set oRng = ActiveDocument.Range
ActiveDocument.Range(0, 0).Select
With oRng.Find
.Text = "_\\ERD"
.Wrap = wdFindStop
If .Execute Then
i = oRng.End
oRng.Collapse direction:=wdCollapseEnd
.Text = "|"
y = Len(.Text) + 1
If .Execute Then
oRng.Select
Set myRange = oRng.Duplicate
myRange.Start = i - 5
myRange.End = oRng.End - y
tmptext = myRange.Text
Debug.Print tmptext
Set oHpl = ActiveDocument.Hyperlinks.Add(myRange, Address:=tmptext,
TextToDisplay:=tmptext)
End If
End If
End With
End Sub
that file) so that the macro makes this replacement for all filenames in the
document.
Note: all my filnames begin with "\\ERD", are followed with a "|", and are
preceeded with "_"
Sub AddHyperlinks2Docs()
Dim myRange As Range
Dim i As Long
Dim y As Long
Dim oHpl As Hyperlink
Set oRng = ActiveDocument.Range
ActiveDocument.Range(0, 0).Select
With oRng.Find
.Text = "_\\ERD"
.Wrap = wdFindStop
If .Execute Then
i = oRng.End
oRng.Collapse direction:=wdCollapseEnd
.Text = "|"
y = Len(.Text) + 1
If .Execute Then
oRng.Select
Set myRange = oRng.Duplicate
myRange.Start = i - 5
myRange.End = oRng.End - y
tmptext = myRange.Text
Debug.Print tmptext
Set oHpl = ActiveDocument.Hyperlinks.Add(myRange, Address:=tmptext,
TextToDisplay:=tmptext)
End If
End If
End With
End Sub