VBA Code
Move shape anchors away from heading paragraphs
When shape anchors are located in heading paragraphs, the table of contents in unable to display heading numbers.
This routine works even on shapes whose anchors are locked.
It preserves the location of a shape even if the shape is positioned relative to paragraph
wdSelectionType.wdSelectionFrame
wdInformation.wdFrameIsSelected
VBA - Links
For Each objField In ActiveDocument.Fields
objField.LinkFormat.BreakLink
Next objField
Public Sub TestThis()
Call changeSource("", "")
End Sub
Public Sub changeSource(ByVal sOldFileName As String, _
ByVal sNewFileName As String)
Dim icount As Integer
Dim iloop As Integer
Dim sfilename As String
On Error GoTo ErrorHandler
icount = ActiveDocument.Fields.Count
For iloop = 1 To icount
If (ActiveDocument.Fields(iloop).Type = wdFieldLink) Then
Debug.Print ActiveDocument.Fields(iloop).OLEFormat.ClassType
Debug.Print ActiveDocument.Fields(iloop).OLEFormat.Label
Debug.Print ActiveDocument.Fields(iloop).OLEFormat.DisplayAsIcon
sfilename = ActiveDocument.Fields(iloop).LinkFormat.SourceFullName
ActiveDocument.Fields(iloop).LinkFormat.SourceFullName = _
Replace(sfilename, sOldFileName, sNewFileName)
End If
Next iloop
Exit Sub
ErrorHandler:
Call MsgBox(Err.Number & " - " & Err.Description)
End Sub
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrev