Results 1 to 15 of 15
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Break Links? (WinXP, Wd2003)

    I'm sure this is just me going mad, and I'm missing something simple, but - what's the line of code to break all links in the activedocument? I thought it would be something like "ActiveDocument.Links.BreakAll" but I just can't find the right syntax!
    <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>
    Any help gratefully appreciated!
    Beryl M


  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    How about
    <code>
    With ActiveDocument.WholeStory.Fields
    .Update
    .Unlink
    End With
    </code>

    If you want to extend to headers, footers and other "special" sections of the document, you'd do well to read Useful Word Procedures by Bryan Carbonnell.

    Alan

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    That would probably work, but I have numerous fields in the document that I don't want to unlink - I only want to break the one external link!

    <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>

    Thanks anyway!
    Beryl M


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

    Re: Break Links? (WinXP, Wd2003)

    For a floating shape:

    Dim sh As Shape
    For Each sh In ActiveDocument.Shapes
    With sh
    If .Type = msoLinkedOLEObject Then
    .LinkFormat.Update
    .LinkFormat.BreakLink
    End If
    End With
    Next sh

    For an inline shape:

    Dim insh As InlineShape
    For Each insh In ActiveDocument.InlineShapes
    With insh
    If .Type = wdInlineShapeLinkedOLEObject Then
    .LinkFormat.Update
    .LinkFormat.BreakLink
    End If
    End With
    Next insh

    The above code is for a linked OLE object, such as an Excel worksheet object. For a floating linked picture, replace msoLinkedOLEObject with msoLinkedPicture; for an inline linked picture, replace wdInlineShapeLinkedOLEObject withwdInlineShapeLinkedPicture.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    Thanks, Hans, but it's none of those! It's an external link, found through Edit, Links, and looks like this on the page:

    { LINK Excel.Sheet.8 lvfsnas01vol2datacommonRATESBASERATE.XLS BASERATE!R2C4 a r * MERGEFORMAT }

    <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45>
    Beryl M


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

    Re: Break Links? (WinXP, Wd2003)

    Depending on whether it's a floating or inline object, the first or second code snippet from my previous reply should work. I tested it just now!

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    I didn't think that fields were objects?
    Beryl M


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

    Re: Break Links? (WinXP, Wd2003)

    Why not?

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    I don't know - I just didn't! Don't objects have to "be" something, like a button, or whatever?!
    Beryl M


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

    Re: Break Links? (WinXP, Wd2003)

    To be or not to be...

    An IncludePicture field is an object, and a Link field can be an object, depending on the way the link has been created. If you select part of an Excel worksheet and Paste Special > Paste Link as an Excel worksheet object, picture or bitmap, you will create a Link field that is also an object.

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    Okay - Well, I ran a line to check how many of the inline and non-inline shapes there were in the document, and it said there were no inline shapes at all, and only two other shapes; but when I ran the non-inline shapes code you supplied it skipped over both objects as not being linked.

    It certainly doesn't seem like this field is being treated as an object!

    It's not a link operated by clicking on anything, or created by pasting a link or anything like that; it's simply a field, created by pressing Ctrl-F9 and typing the content (literally, the code that creates the document does it manually using Selection.TypeText); then once created it shows up in Edit, Links as I mentioned.

    The thing is I need to unlink this field, leaving the current result, without touching any of the 30 or 40 other fields in the document!
    Beryl M


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

    Re: Break Links? (WinXP, Wd2003)

    Does this work?

    Dim fld As Field
    For Each fld In ActiveDocument.Fields
    If fld.Type = wdFieldLink Then
    fld.Update
    fld.Unlink
    End If
    Next fld

  13. #13
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    That's the b**ger!!

    Thanks, Hans, I knew you wouldn't let me down!

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Beryl M


  14. #14
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    This sounds like quite a different requirement from your original question: <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    > what's the line of code to break all links in the activedocument?

    If you know the particular field you want to unlink, you can select it, then run the simple macro:
    <code>
    Sub BreakSelectedLink()
    Selection.Fields.Unlink
    End Sub
    </code>
    Alan

  15. #15
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Break Links? (WinXP, Wd2003)

    I suppose it does - sorry! - but it wasn't meant that way. At the time I was thinking it of it as the only link in the document, not realising that it was one of many fields, but the only linked one ... my usual problem with terminology!

    I like your solution, by the way, which would indeed have the desired effect!
    Beryl M


Posting Permissions

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