Break the links (Ctrl+Shift+F9) on IncludePicture-Fields using VBA

Posted on 2011-10-04
Last Modified: 2012-05-12
Dear Experts:

 I got a lot of 'IncludePicture'-Fields.

How do I break the links only on those fields (i.e. Ctrl + Shift + F9) leaving all the other field types alone.

This action should be realized on the active Document using a VBA code.

If no 'IncludePicture'-Fields are found the macro is to say so, if there are any and the links have been broken,  a msgbox should retrieve the number of links broken.

Help is more than appreciated. Thank you very much in advance for your valuable help.

Regards, Andreas

Question by:AndreasHermle
    LVL 17

    Accepted Solution

    Give this a try:
    Public Sub RemovePicLinks()
        Dim f As Word.Field
        Dim i As Long
        Dim lngCount As Long
        Dim strMessage As String
        For i = ActiveDocument.Fields.Count To 1 Step -1
            Set f = ActiveDocument.Fields(i)
            If f.Type = wdFieldIncludePicture Then
                lngCount = lngCount + 1
            End If
        Next i
        If lngCount > 0 Then
            strMessage = "Complete - " & CStr(lngCount) & " picture links were broken"
            strMessage = "Complete - no picture links were broken"
        End If
        MsgBox strMessage
    End Sub

    Open in new window


    Author Closing Comment

    Hi Andrew:
      great job, this did the trick.  Thank you very much for your professional help.

    Regards, Andreas

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
    This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
    Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now