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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Rgonzo1971Commented:
could you send a dummy?
0
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.