Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 05-19-2011, 07:16 PM
macropod's Avatar
macropod macropod is offline Need good source on 2007 graphics features Windows 7 32bit Need good source on 2007 graphics features Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Hi samhdc,

Here are two macros for updating image links. They both handle inline and floating images. The first one processes all images in the document; the second one processes only the selected image(s).
Code:
Sub UpdateAllImageLinks()
Dim oShp As Shape, iShp As InlineShape, RngStry As Range, OldPath As String, NewPath As String
With ThisDocument
  For Each RngStry In .StoryRanges
    For Each oShp In RngStry.ShapeRange
      With oShp
        .Select
        If Not .LinkFormat Is Nothing Then
          OldPath = .LinkFormat.SourcePath
          NewPath = InputBox("Update Path", "Image Path Update", OldPath)
          If NewPath = "" And OldPath <> "" Then Exit Sub
          ' Replace the link to the external file if they differ.
          If OldPath <> NewPath Then
            .LinkFormat.SourceFullName = Replace(.LinkFormat.SourceFullName, OldPath, NewPath)
          End If
        End If
      End With
    Next oShp
    For Each iShp In .InlineShapes
      With iShp
        .Select
        If Not .LinkFormat Is Nothing Then
          OldPath = .LinkFormat.SourcePath
          NewPath = InputBox("Update Path", "Image Path Update", OldPath)
          If NewPath = "" And OldPath <> "" Then Exit Sub
          ' Replace the link to the external file if they differ.
          If OldPath <> NewPath Then
            .LinkFormat.SourceFullName = Replace(.LinkFormat.SourceFullName, OldPath, NewPath)
          End If
        End If
      End With
    Next iShp
  Next RngStry
End With
End Sub
Code:
Sub UpdateOneImageLink()
Dim oShp As Shape, iShp As InlineShape, RngStry As Range, OldPath As String, NewPath As String
With Selection
  For Each oShp In .ShapeRange
    With oShp
      If Not .LinkFormat Is Nothing Then
        OldPath = .LinkFormat.SourcePath
        NewPath = InputBox("Update Path", "Image Path Update", OldPath)
        If NewPath = "" And OldPath <> "" Then Exit Sub
        ' Replace the link to the external file if they differ.
        If OldPath <> NewPath Then
          .LinkFormat.SourceFullName = Replace(.LinkFormat.SourceFullName, OldPath, NewPath)
        End If
      End If
    End With
  Next oShp
  For Each iShp In .InlineShapes
    With iShp
      If Not .LinkFormat Is Nothing Then
        OldPath = .LinkFormat.SourcePath
        NewPath = InputBox("Update Path", "Image Path Update", OldPath)
        If NewPath = "" And OldPath <> "" Then Exit Sub
        ' Replace the link to the external file if they differ.
        If OldPath <> NewPath Then
          .LinkFormat.SourceFullName = Replace(.LinkFormat.SourceFullName, OldPath, NewPath)
        End If
      End If
    End With
  Next iShp
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 12:47 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