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

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

Hi,
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.
0
StevenMiles
Asked:
StevenMiles
  • 3
  • 2
1 Solution
 
GrahamSkanCommented:
Can you post a small sample portion of the document, please, so that we can be sure what we are dealing with?
0
 
StevenMilesAuthor Commented:
Sure. Here's a sliver:

http://app25.com/EmbedOrLink.docx

I'm embarrassed to report that the full document is hundreds of megabytes.
/SD
0
 
GrahamSkanCommented:
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\"
Do
    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
                rng.Delete
                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

0
 
StevenMilesAuthor Commented:
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
0
 
GrahamSkanCommented:
Thanks.
Can you give us an idea of what the workaround is, please?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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