Macro to lock all links in Word Doc

G

Gary

I have Word documents that contain links to Excel charts.
I need a macro that can automatically lock all links in
the Word Document. Does anyone have the code handy?
Thanks, regards,
Gary
 
J

JGM

Hi Gary,

One of the problem is that Word treats graphics that are in line with the
text as inline shapes, or fields if they are linked, and floating or wrapped
graphics as objects. The following code should take care of both.

'_______________________________________
Sub Lock_All_Linked_Objects()

Dim MyShape As Shape
Dim MyField As Field
Dim i As Integer

For Each MyShape In ActiveDocument.Shapes
With MyShape
If .Type = msoLinkedOLEObject Then
If Not .LinkFormat.Locked Then .LinkFormat.Locked = True
End If
End With
Next MyShape

For i = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(i)
If .Type = wdFieldLink Then
If Not .LinkFormat.Locked Then .LinkFormat.Locked = True
End If
End With
Next i

End Sub
'_______________________________________

Anyone knows of a way to handle both at the same time?

HTH
Cheers!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top