G
GainesvilleWes via OfficeKB.com
Good morning,
First off I would like to thank everyone on the fourms here for the help they
have given me over the last 2 weeks. You guys, (and gals), are wonderful.
Bravo Zulu.
Okay, I have the maco, (shown below, also aquired from these fourms), that
changes the source links in a word doc (to an excel worksheet) for all but
the one link in the header. What code would i add to this to change the link
in the header also?
---------------------------
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
Dim Message, Title, Default, Newfile
Dim counter As Integer
Dim docPath As String
' Sets docPath to the .xls file in the user created directory
docPath = Replace$(ActiveDocument.Path & "\Mercury Commitment Excel
Worksheet.xls", "\", "\\") & "\\"
' Changes links to new path
counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then
Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Default = linkfile
End If
linkcode.Text = linktype & docPath & linklocation
counter = counter + 1
End If
Next alink
First off I would like to thank everyone on the fourms here for the help they
have given me over the last 2 weeks. You guys, (and gals), are wonderful.
Bravo Zulu.
Okay, I have the maco, (shown below, also aquired from these fourms), that
changes the source links in a word doc (to an excel worksheet) for all but
the one link in the header. What code would i add to this to change the link
in the header also?
---------------------------
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
Dim Message, Title, Default, Newfile
Dim counter As Integer
Dim docPath As String
' Sets docPath to the .xls file in the user created directory
docPath = Replace$(ActiveDocument.Path & "\Mercury Commitment Excel
Worksheet.xls", "\", "\\") & "\\"
' Changes links to new path
counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then
Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Default = linkfile
End If
linkcode.Text = linktype & docPath & linklocation
counter = counter + 1
End If
Next alink