View Single Post
 
Old 12-07-2020, 01:25 PM
dinofanatic dinofanatic is offline Windows 10 Office 2019
Novice
 
Join Date: Nov 2020
Posts: 5
dinofanatic is on a distinguished road
Default

Got it working! Ended up having to include a loop to specifically search the footers.

Code:
For j = 1 To ThisDocument.Sections.Count
For j = 1 To ThisDocument.Sections.Count
  For k = 1 To 3
    For Each Fld In ThisDocument.Sections(j).Footers(k).Range.Fields
      With Fld
        ' Skip over fields that don't have links to external files.
        If Not .LinkFormat Is Nothing Then
          With .LinkFormat
            ' Replace the source filename with the new filename
            OldPath = Left(.SourceFullName, InStrRev(.SourceFullName, "\"))
            OldFile = .SourceName
            StrTmp = Replace(.SourceFullName, OldPath, NewPath)
            StrTmp = Replace(StrTmp, OldFile, NewFile)
            ' Replace the link to the external file if it differs.
            If .SourceFullName <> NewPath & NewFile Then
              .SourceFullName = StrTmp
              On Error Resume Next
              .AutoUpdate = False
              On Error GoTo 0
            End If
          End With
        End If
      End With
    Next Fld
  Next k
Next j
Reply With Quote