Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inlineshapes - removing links to (WordXP)

    We insert pictures in our documents as links (to save space in the documents). The code we use is something like:

    Selection.InlineShapes.AddPicture _
    FileName:=sFilename, _
    LinkToFile:=True, SaveWithDocument:=False

    When we send files via e-mail we want to paste the pictures into the documents (removing the link). This can be achieved by copying the picture and pasting it into the document manually, however, I can't do this programmatically. For some reason it always stays linked.

    Can anyone help?

  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: Inlineshapes - removing links to (WordXP)

    If you press Alt+F9, those linked inline pictures should be revealed to be INCLUDEPICTURE fields. As such, like many other types of fields, they can be "unlinked" and the results locked in by selecting them and pressing Ctrl+Shift+F9. Now... to do that programmatically, you might comb through the fields collection and unlink all the INCLUDEPICTURE fields. Not sure if there's a way to do that through the InlineShapes collection.

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inlineshapes - removing links to (WordXP)

    Thanks jscher2000. That works brilliantly.

    I wasn't aware that inlineshapes were fields. I tried unlinking the inlineshapes but couldn't do it. However, unlinking the fields works! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Inlineshapes - removing links to (WordXP)

    You don't need to go through the entire Fields collection looking for inline shapes. You can go through all the InlineShapes with code like

    For Each shp in ActiveDocument.InlineShapes
    if shp.Type = wdInlineShapeLinkedPicture Then
    shp.Field.Unlink
    next

    You may also want to check for a type of wdInlineShapeLinkedOLEObject or wdInlineShapeLinkedPictureHorizontalLine.

    After a bit more testing
    It is even simpler to use
    If shp.Range.Fields.Count > 0 Then

    StuartR

  5. #5
    Star Lounger
    Join Date
    Jan 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inlineshapes - removing links to (WordXP)

    I found that for Pictures that were in the headers, that I had to look through the headers to unlink them. Has Word defined that headers are outside the activedocument area?
    It seems that you can unlink them without looking through all the headers and footers within each section of the document.

  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: Inlineshapes - removing links to (WordXP)

    > It seems that you can unlink them without looking through all the headers and footers within each section of the document.

    If you meant "can't," I agree. Certainly checking every section is the only way to guarantee you got them all.

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Inlineshapes - removing links to (WordXP)

    A word document consists of a number of StoryRanges. These include the main flow of text (ActiveDocument), the comments, the first page header, odd page header and even page header for each section, all end notes etc.

    A macro that looks at Each something-or-other in ActiveDocument will not find things in the other story ranges. If you want to see some examples of code that manipulates an entire document then search this forum for StoryRange

    StuartR

Posting Permissions

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