Hi Evan
When inserting an inline shape into your document/template you have two
options. You can either link to the original picture or not. Doing this:
Insert>Picture>From File>Insert, generates this code:
Selection.InlineShapes.AddPicture FileName:="C:\bath.jpg", _
LinkToFile:= False, SaveWithDocument:=True
However, doing this: Insert>Picture>From File>Link to file, generates this
code:
Selection.InlineShapes.AddPicture FileName:="C:\bath.jpg", _
LinkToFile:= True, SaveWithDocument:=False
Both of these statements generate InlineShape objects. However, when you
set LinkToFile to True, Word inserts an INCLUDEPICTURE field. You can only
unlink InlineShapes that have a corresponding field.
The problem with your code is that the shape you are processing at the time
your code bombs has no LinkFormat object (it's actually Nothing). In other
words the InlineShapes not linked it's embedded.
So try the following:
Public Sub UnlinkInlineShapes()
Dim IShape As Word.InlineShape
For Each IShape In ActiveDocument.InlineShapes
With IShape
If Not .LinkFormat Is Nothing Then
Debug.Print "Unlinking: " & .LinkFormat.SourceFullName
.LinkFormat.BreakLink
End If
End With
Next IShape
End Sub
HTH + CHeers - Peter