So between that original link, the new code posted here, and some googling I think I've managed to get close to what I would like to achieve. The problem I'm currently having is running into
Run-Time Error '6083'
Objects in this document contain links to files that cannot be found.
The linked information will not be updated.
at the ".SourceFullName = Replace(.SourceFullName, OldPath, NewPath)" line. I've manually added the kb 70154 registry patch that was referenced in a couple forums. Also went through and made sure all automatic update switches were removed.
1) Anything else I can try?
2) Does this macro also replace links in footers?
3) Am I on the right track with this code? Here's a snippet of the relevant sections:
...
' Set the new filename
NewFile = Split(ActiveDocument.Name, ".")(0)
NewFile = Replace(NewFile, "Final Report", "Tables")
...
' Go through the fields in the story range.
For Each Fld In Rng.Fields
With Fld
' Skip over fields that don't have links to external files.
If Not .LinkFormat Is Nothing Then
With .LinkFormat
OldPath = Left(.SourceFullName, InStrRev(.SourceFullName, ""))
' Replace the link to the external file if it differs.
If OldPath <> NewPath Then
.SourceFullName = Replace(.SourceFullName, OldPath, NewPath)
' Replace the source filename with the new filename
OldFile = Split(.SourceName, ".")(0)
.SourceFullName = Replace(.SourceFullName, OldFile, NewFile)
On Error Resume Next
.AutoUpdate = False
On Error GoTo 0
|