lock all the linked graphics by means of VBA

Dear Experts:

In my current document I would like to lock all the linked fields of the type 'graphic' as you can see on the screen shot by means of VBA.

lock graphics via VBA
Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Andreas HermleTeam leaderAsked:
Who is Participating?
 
Rgonzo1971Commented:
then try
Sub macro()
For Each fld In ActiveDocument.Fields
    If fld.Type = wdFieldIncludePicture Then
        fld.Locked = True
    End If
Next
End Sub

Open in new window

0
 
Rgonzo1971Commented:
Hi,

pls try
Sub macro()
For Each fld In ActiveDocument.Fields
    If fld.Type = wdFieldLink Then
        If fld.LinkFormat.Type = wdLinkTypePicture Then
            fld.Locked = True
        End If
    End If
Next
End Sub

Open in new window

EDITED CODE

Regards
0
 
Andreas HermleTeam leaderAuthor Commented:
Hi Rafael,

thank you very much for your great help. I am afraid to tell you that the graphics do not get locked with your Code, although the code looks perfect to me. Any idea why?

Regards, Andreas
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Rgonzo1971Commented:
could you send a dummy?
0
 
Andreas HermleTeam leaderAuthor Commented:
ok, later totday, thank you very much.
0
 
Andreas HermleTeam leaderAuthor Commented:
Here you are, Rafael, thank you very much in advance for your efforts

linked_graphics_locking.doc
0
 
Andreas HermleTeam leaderAuthor Commented:
Excactly what I was looking for. Thank you very much. The fld.Type = wdFieldIncludePicture was the key to the solution.

Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.