Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-06-2015, 01:57 PM
macropod's Avatar
macropod macropod is offline Changing Field Links in a Word Document from one excel file to another Windows 7 64bit Changing Field Links in a Word Document from one excel file to another Office 2010 32bit
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

Given that it's possible for the links to exist in something other than fields, try:


Code:
Sub Update_Links()
'
' Update_Link Macro
'
Dim Rng As Range, i As Long, vItem As Variant
'
'Display File Picker Dialog
With Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
  ' use Show method to dispaly File Picker dialog box and return user's action
  If .Show = -1 Then
  'step throug each string in the FileDialogSelectedItems collection
    vItem = .SelectedItems(1)
  Else
    Exit Sub
  End If
End With
'
'update fields
'
Application.ScreenUpdating = False
With ActiveDocument
  For Each Rng In .StoryRanges
    With Rng
      For i = .Fields.Count To 1 Step -1
        If .Fields(i).Type = wdFieldLink Then .Fields(i).LinkFormat.SourceFullName = vItem
      Next
      For i = .ShapeRange.Count To 1 Step -1
      If Not .ShapeRange(i).LinkFormat Is Nothing Then .ShapeRange(i).LinkFormat.SourceFullName = vItem
      Next
      For i = .InlineShapes.Count To 1 Step -1
        If Not InlineShapes(i).LinkFormat Is Nothing Then InlineShapes(i).LinkFormat.SourceFullName = vItem
      Next
    End With
  Next
End With
'
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
header and footer, link, update



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Field Links in a Word Document from one excel file to another How can I save a Word Document as a PDF file with a merged field filename? kp2009 Word VBA 5 08-27-2015 11:45 PM
How can I embed a word document so I don't lose the links therein Dracven Outlook 2 03-31-2014 04:02 AM
Using Quick Parts >> Ref >> Field (Third word changing font) sonny49 Word 1 01-07-2014 10:01 AM
Embedded Links failing in word document jim_jim Word 0 02-05-2013 07:48 AM
Edits links to Excel file in PowerPoint ziba PowerPoint 4 01-09-2012 08:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:10 PM.


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