Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2018, 06:43 AM
odinivan odinivan is offline Change link path to a number of figures efficiently Windows 10 Change link path to a number of figures efficiently Office 2016
Novice
Change link path to a number of figures efficiently
 
Join Date: Nov 2018
Posts: 2
odinivan is on a distinguished road
Lightbulb Change link path to a number of figures efficiently

Hello,


I have a report with over 100 linked figures. Unfortunately I had to change to path the where the figures are located, and as a consequence I need to change all the links in the document. I tried using ALT+F9 as described here https://wordribbon.tips.net/T010524_...s_in_Documents, but could not see the text for the file paths, hence could I not replace the old path with the new. I am guessing this has to do with the Word version. How can I solve this in Word 2016?

Thank you so much in advance

Last edited by Charles Kenyon; 11-08-2018 at 12:55 PM. Reason: Mark as solved
Reply With Quote
  #2  
Old 11-07-2018, 07:46 AM
gmayor's Avatar
gmayor gmayor is offline Change link path to a number of figures efficiently Windows 10 Change link path to a number of figures efficiently Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You could save the file in the compatibility mode of an earlier version that had the links available as described, then replace the path in the field, update the field and save it back in the compatibility mode of the current version. It should work fine provided you have not used any more recent features in the document, such as some content control types applicable only to later versions of Word.

Put the new path where indicated at the top of the macro and run the macro on a copy of your document.
Code:
Sub ChangeLink()
'Graham Mayor - http://www.gmayor.com - Last updated - 07 Nov 2018
Const NewPath As String = "C:\\Path\\"
Dim oFld As Field
Dim strCode As String
Dim vName As Variant
    ActiveDocument.SaveAs2 FileName:=ActiveDocument.FullName, CompatibilityMode:=11
    For Each oFld In ActiveDocument.Fields
        If oFld.Type = wdFieldIncludePicture Then
            vName = Split(oFld.Code, "\\")
            strCode = " INCLUDEPICTURE " & Chr(34) & NewPath & vName(UBound(vName))
            oFld.Code.Text = strCode
            oFld.Update
        End If
        ActiveDocument.SaveAs2 FileName:=ActiveDocument.FullName, CompatibilityMode:=Val(Application.Version)
    Next oFld
lbl_Exit:
    Set oFld = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 11-07-2018, 03:35 PM
macropod's Avatar
macropod macropod is offline Change link path to a number of figures efficiently Windows 7 64bit Change link path to a number of figures efficiently Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I'd approach the task differently, allowing for the possibility that some linked 'figures' might not use a picture format:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
Const strPath As String = "C:\NewPath\"
With ActiveDocument
  For i = .Shapes.Count To 1 Step -1
    With .Shapes(i)
      If Not .LinkFormat Is Nothing Then
        With .LinkFormat
          .SourceFullName = strPath & .SourceName
        End With
      End If
    End With
  Next
  For i = .InlineShapes.Count To 1 Step -1
    With .InlineShapes(i)
      If Not .LinkFormat Is Nothing Then
        With .LinkFormat
          .SourceFullName = strPath & .SourceName
        End With
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 11-08-2018, 12:53 AM
odinivan odinivan is offline Change link path to a number of figures efficiently Windows 10 Change link path to a number of figures efficiently Office 2016
Novice
Change link path to a number of figures efficiently
 
Join Date: Nov 2018
Posts: 2
odinivan is on a distinguished road
Default

What if I only want to change part of the path? The figures are in different subfolders, and actually the only thing I want to change is "046" to "048" in all of the file links.
Reply With Quote
  #5  
Old 11-08-2018, 03:21 AM
gmayor's Avatar
gmayor gmayor is offline Change link path to a number of figures efficiently Windows 10 Change link path to a number of figures efficiently Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming the number only appears once in the link path, then Paul's code can be modified e.g.


Code:
Sub Demo()
    Application.ScreenUpdating = False
    Dim i As Long
    With ActiveDocument
        For i = .Shapes.Count To 1 Step -1
            With .Shapes(i)
                If Not .LinkFormat Is Nothing Then
                    With .LinkFormat
                        .SourceFullName = Replace(.SourceFullName, "046", "048")
                    End With
                End If
            End With
        Next
        For i = .InlineShapes.Count To 1 Step -1
            With .InlineShapes(i)
                If Not .LinkFormat Is Nothing Then
                    With .LinkFormat
                        .SourceFullName = Replace(.SourceFullName, "046", "048")
                    End With
                End If
            End With
        Next
    End With
    Application.ScreenUpdating = True
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change link path to a number of figures efficiently Link image using file path Jue92 Word 2 10-17-2016 01:09 AM
Change link path to a number of figures efficiently Figure Captioning Labels All Figures As Number 1 AnonAccount Word 3 03-31-2015 10:44 PM
Change link path to a number of figures efficiently Change old path to new path (batch) NobodysPerfect Word VBA 2 08-14-2014 10:09 PM
How do I permanently update the file name path in the Data Link properties? lynnwalder Mail Merge 2 05-20-2013 11:38 AM
Change link path to a number of figures efficiently Relative path for video link? Is it possible? Baudisson PowerPoint 1 01-10-2012 02:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:35 AM.


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