View Single Post
 
Old 07-07-2015, 03:55 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit 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

Quote:
Originally Posted by Fed77 View Post
I'm quite confuse:

1) If I run last macro you posted, everything is working except header link

2) If I insert macro's text in an AutoOpen macro (to run it automatically when I open word), every link is updated (IN THE HEADER TOO) but it shows the entire worksheet!!!!
There is no reason I'm aware of for either behaviour - whichever way you run the macro, all links should be updated with the same content as before. That said, try the following:
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
          .Fields(i).Update
        End If
      Next
      For i = .ShapeRange.Count To 1 Step -1
        If Not .ShapeRange(i).LinkFormat Is Nothing Then
          .ShapeRange(i).LinkFormat.SourceFullName = vItem
          .ShapeRange(i).LinkFormat.Update
        End If
      Next
      For i = .InlineShapes.Count To 1 Step -1
        If Not .InlineShapes(i).LinkFormat Is Nothing Then
          .InlineShapes(i).LinkFormat.SourceFullName = vItem
          .InlineShapes(i).LinkFormat.Update
        End If
      Next
    End With
  Next
End With
'
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote