How do I convert embedded images to linked images in Word 2007

Posted on 2014-07-15
Last Modified: 2014-07-18
I have a very large Word document. It is created by copying a large HTML page from Chrome and pasting it into Word. Works great. All of the images displayed in the HTML page are in two directories. For example, the <img> tags might look like this:
<img src="../my/images/dir_1/Picture1.jpg">
<img src="../my/images/dir_2/PictureA.jpg">

When I create the Word file by pasting from the browser, the images are all embedded in the .docx. Since one image might appear even 500 times in the document, I'd like to try having the images linked instead of embedded, to hold down the size of the .docx file. How do I make that happen? I'm familiar with writing macros, but not for a task like this.

Thanks for any help.
Question by:StevenMiles
    LVL 76

    Expert Comment

    Can you post a small sample portion of the document, please, so that we can be sure what we are dealing with?

    Author Comment

    Sure. Here's a sliver:

    I'm embarrassed to report that the full document is hundreds of megabytes.
    LVL 76

    Accepted Solution

    Officially, there is no pointer in an embedded picture to its original file. However, it looks as if the default value for the AlternativeText property is the filename. One complication is that, in the document that you provided, the property shows the full filename. In my attempt to reproduce the situation here, only the filename appears. The path is omitted. Therefore this macro allows  for a default path which is used if no path is found in the name.
    Sub ChangeToLink()
    Dim ilsh As InlineShape
    Dim strFileName As String
    Dim rng As Range
    Dim bFound As Boolean
    Dim strPicturesFolder As String
    strPicturesFolder = "C:\MyPictures\"
        bFound = False
        For Each ilsh In ActiveDocument.InlineShapes
            Set rng = ilsh.Range
            strFileName = ilsh.AlternativeText
            Debug.Print "1", strFileName
            If Len(strFileName) > 0 Then
                If ilsh.LinkFormat Is Nothing Then
                    If InStr("\", strFileName) = 0 Then
                        strFileName = strPicturesFolders & strFileName
                    End If
                    ActiveDocument.InlineShapes.AddPicture strFileName, True, False, rng
                    bFound = True
                    Exit For
                End If
            End If
        Next ilsh
    Loop While bFound
    End Sub

    Open in new window


    Author Closing Comment

    Hmm. Very interesting Graham. Not really what I was looking for, but maybe I can use it on another project.

    For the current problem, I found a workaround. Thanks
    LVL 76

    Expert Comment

    Can you give us an idea of what the workaround is, please?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    I. Introduction In a previous article ( (now deprecated), I discussed how to upgrad…
    This article provides the solution to a question ( posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
    The goal of the tutorial is to teach the user what exposure is and how to use the exposure slider. Analyze the photo that you want to edit, then adjust the exposure slider to your liking.
    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 …

    779 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

    18 Experts available now in Live!

    Get 1:1 Help Now