• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 893
  • Last Modified:

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

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

1 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

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

Regards, Andreas

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now