Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    How to copy all 'INCLUDEPICTURE' fields to a file? (Word 2003 SP2)

    Hello,

    First of all, I am using MS Word 2003 with Windows XP SP2.

    I have a word document with multiple graphics that are all imported by reference. The graphics are in multiple folders under a root graphic folder.

    Now, I can toggle the codes to show the "INCLUDEPICTURE" field/path of each graphic, but what I would like to do now is to somehow copy all the entries (fields) and paste them into a spreadsheet, for tracking purposes.

    Does anyone know a way in which I can copy all those field entries to clipboard memory, such that what is copied to memory is the exact "INCLUDEPICTURE field/path?

    Thanks for the feedback in advance.

    Regards,

    Jim

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    <P ID="edit" class=small>(Edited by jscher2000 on 17-Jan-07 10:39. Added a note)</P>The following quick and dirty macro should extract the URLs and list them in a new Word document:

    <code>Sub ListOfIncludePicturePaths()
    Dim docExisting As Word.Document, fld As Word.Field, _
    docNew As Word.Document, strTemp() As String
    Set docExisting = ActiveDocument
    With docExisting
    If .Fields.Count > 0 Then
    For Each fld In .Fields
    If fld.Type = wdFieldIncludePicture Then
    If (docNew Is Nothing) Then Set docNew = Documents.Add
    strTemp = Split(fld.Code, """")
    docNew.Content.InsertAfter strTemp(1) & vbCrLf
    End If
    Next
    End If
    End With
    If Not (docNew Is Nothing) Then
    docNew.Activate
    Set docNew = Nothing
    End If
    Set docExisting = Nothing
    End Sub</code>

    I only tested in a very simple page (copy and paste of Google home page), so if you have a very complex case, some unforeseen issues might arise.

    Added: By the way, I see you're new here. Welcome to the Lounge. When you copy and paste code from the Lounge into the VB Editor, sometimes all the line breaks disappear. It is best to first create a blank Word document, paste there, and then you can copy and paste from the document into the VB Editor. If you haven't used web code samples before, you can follow this post on how to get the code into a macro: <IMG SRC=http://www.wopr.com/w3timages/starpost.gif> Creating your first Macro in Word

  3. #3
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    Hello Jscher2000,

    Wow! This works like a champ! Thanks so much.

    I have a follow up question on my original post, that I am hoping you can answer. Here it is.

    I have a folder with several hundred word documents in the folder. Most of the word documents have graphics that are linked to several graphic folders.
    I would like to find a way of running this Macro, so that it could search every word document in this folder and then dump out INCLUDEPICTURE links from each document - into a new document, as was accomplished with your first code example. The second thing is that I need it to find instances where the graphic may have been embedded versus linked. I will take all this end result data and put it onto a spreadsheet - for tracking purposes.
    One again, I really appreciate any information you can pass my way.

    Thanks again for the quick response time. It is appreciated.

    Regards,

    Jim

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    I have attached an expanded version of Jefferson's macro.
    It prompts the user to select a folder, then loops through all documents (.doc files) in the folder, and lists the file names from INCLUDEPICTURE fields into a new document.
    Attached Files Attached Files

  5. #5
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    Hello Hans,

    This appended script works great. Do you know how to find graphics that are embedded versus linked? I need to track documents with embedded graphics also. How do I add add to the code to show the embedded graphics too? Thanks for the quick response.

    Jim

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    You may have noticed that the EMBED field does not display the original source path. In some cases, this information simply will not be available, such as when the field was generated by copying and pasting a selection from an image editing application. In other cases, it might be possible to dig it out using extreme measures because the information often is (or at least in earlier versions of Word was) retained deep in the invisible recesses of Word's binary file structure. However, I can't recall the trick to doing that (if I ever knew...).

  7. #7
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    Hello Jefferson,

    Thanks for the response. Hey, I look at it this way, I am a lot better off then I was before I posted here. Thanks to you and Hans for the rapid feedback. This is my first day on this forum and I am impressed. As far as the embed tag goes, I will dig around some more on the web, but I appreciate the inputs. Jim

  8. #8
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    Hello Jefferson / Hans,

    One last question if I may? Is it possible to modify that Macro so that it will find Text Boxes within a folder full of word documents or is this the same problem as trying to find instances where graphics are embedded? I know that if the word document is saved as a HTML file, then I can look at the code and see that the text box is shown as: <v:textbox> and </v:textbox> with gradient and fill information in the middle. Can the Macro be edited to search for the textbox reference when run and then added to the output file? I know that I have graphics in these textboxes and I can indirectly find the graphics that way. Overall, I am trying to better manage an existing folder system. Once again. I appreciate the feedback. -J

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    Instead of or in addition to looping through all fields in a document, you can loop through its Shapes collection and/or its InlineShapes collection. You can then inspect the Type property of each object.
    For (floating) Shapes, you'd be interested in objects of type msoEmbeddedOLEObject, msoLinkedOLEObject, msoLinkedPicture, msoPicture and msoTextBox, and for InlineShapes in objects of type wdInlineShapeEmbeddedOLEObject, wdInlineShapeLinkedOLEObject, wdInlineShapeLinkedPicture and wdInlineShapePicture.
    You can write one or more properties of these objects to the new document.

    Is that enough to confuse you? <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  10. #10
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: How to copy all 'INCLUDEPICTURE' fields to a f

    Hey Hans,

    Thanks! I will try your approach. No worries, the confusion goes away when the caffeine kicks in... :-) - bring on the espressos!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •