View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Karl Kvool Karl Kvool is offline
external usenet poster
 
Posts: 3
Default Moving Links to Objects in Current Folder

Well, I poked around in the Word Object Model and thought I could write a
Macro that would point all linked objects to the current folder. The thing
works great except for one major flaw. The .Headers collection of the
ActiveDocument.Section(1) appears to be returning the **Footer** ? It tells
me its a header but I know for a fact its the footer because I put different
alt-text on the shape in the header and the footer. And the footer shape's
at text is what shows up every time. As of right know I need some serious
help accessing the shapes in the header. I can change all of the other
shapes in the document.

Here is the code for the macro which is attempting to change the header
shapes' .LinkSource.SourceFullName. I included the FixBodyLinks, which wil
take care of everything that is not in a header or footer.

Private Sub FixHeaderLinks()
Dim s As Shape
Dim sec As Section
Dim h As HeaderFooter
Dim NewPath as String
NewPath = ActiveDocument.Path)
With ActiveDocument
For Each sec In .Sections
For Each h In sec.Headers
If (h.IsHeader) Then
MsgBox ("I am a header")
Else
MsgBox ("I am NOT a header")
End If
For Each s In h.Shapes
MsgBox ("I am header shape " + s.Name + " and my alttext
is " + s.AlternativeText)
With s
If .Type = msoLinkedOLEObject Then
With .LinkFormat
.SourceFullName = Replace(.SourceFullName,
..SourcePath, NewPath)
.AutoUpdate = True
End With
End If
End With
Next s
Next h
Next sec
End With
End Sub

Private Sub FixBodyLinks(NewPath As String)
Dim s As Shape

For Each s In ActiveDocument.Shapes
With s
If .Type = msoLinkedOLEObject Then
With .LinkFormat
.SourceFullName = Replace(.SourceFullName, .SourcePath,
NewPath)
.AutoUpdate = True
End With
End If
End With
Next s
End Sub