Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 12-07-2020, 01:25 PM
dinofanatic dinofanatic is offline autofldupdt macro - Modifying to keep part of file name Windows 10 autofldupdt macro - Modifying to keep part of file name Office 2019
Novice
autofldupdt macro - Modifying to keep part of file name
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Corrupted Footnotes After Modifying File on Macbook! MusculaR_MinD Word 3 12-12-2019 06:09 PM
autofldupdt macro - Modifying to keep part of file name macro to change part of the name of an existing Word file justinmo Word VBA 2 09-11-2018 06:08 PM
Modifying RTF File in MS Word 2007 Nickster Word VBA 2 12-02-2015 11:33 PM
autofldupdt macro - Modifying to keep part of file name Copying a part of a docx file as a separate file officeboy09 Word 6 09-26-2014 05:15 PM
autofldupdt macro - Modifying to keep part of file name modifying a PST file ctspwc Outlook 5 11-17-2010 09:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft