Getting rid of hyperlinks

Discussion in 'Word VBA Beginners' started by Oz Springs, Jan 14, 2005.

  1. Oz Springs

    Oz Springs Guest

    I have received a document which is choc-a-block with linked email addresses
    which make it hard for me to copy and paste. I don¹t need the links at all.

    I have created a macro which goes from one field to the next to remove the
    link, and the procedure is semi manual, but I am wondering if there is a
    better way of doing this. Is there a way of telling all the links to go away
    via a macro?

    Thanks for any help




    Oz
     
    Oz Springs, Jan 14, 2005
    #1
    1. Advertisements

  2. "Oz Springs" <> wrote in message
    news:BE0D93A0.25AD%...
    >I have received a document which is choc-a-block with linked email
    >addresses
    > which make it hard for me to copy and paste. I don¹t need the links at
    > all.
    >
    > I have created a macro which goes from one field to the next to remove the
    > link, and the procedure is semi manual, but I am wondering if there is a
    > better way of doing this. Is there a way of telling all the links to go
    > away
    > via a macro?


    Hi Oz

    Yup, there is.

    Sub RemoveHyperlinks()
    Dim n as Long
    With ActiveDocument.Hyperlinks
    For n = 1 to .Count
    .Item(1).Delete
    Next n
    End With
    End Sub

    This will remove all hyperlinks and leave all other fields intact.


    --
    Regards
    Jonathan West - Word MVP
    www.intelligentdocuments.co.uk
    Please reply to the newsgroup
     
    Jonathan West, Jan 14, 2005
    #2
    1. Advertisements

  3. Oz Springs

    Oz Springs Guest

    Thank you very much. A reply in 7 minutes. I didn¹t even have enough time to
    return to my laborious semi-manual hyperlink removal.

    Kind regards



    Oz


    On 14/1/05 15:27, in article uVhuF2k#,
    "Jonathan West" <> wrote:

    >
    > "Oz Springs" <> wrote in message
    > news:BE0D93A0.25AD%...
    >> I have received a document which is choc-a-block with linked email
    >> addresses
    >> which make it hard for me to copy and paste. I don¹t need the links at
    >> all.
    >>
    >> I have created a macro which goes from one field to the next to remove the
    >> link, and the procedure is semi manual, but I am wondering if there is a
    >> better way of doing this. Is there a way of telling all the links to go
    >> away
    >> via a macro?

    >
    > Hi Oz
    >
    > Yup, there is.
    >
    > Sub RemoveHyperlinks()
    > Dim n as Long
    > With ActiveDocument.Hyperlinks
    > For n = 1 to .Count
    > .Item(1).Delete
    > Next n
    > End With
    > End Sub
    >
    > This will remove all hyperlinks and leave all other fields intact.
    >
     
    Oz Springs, Jan 14, 2005
    #3
  4. Oz Springs

    Jay Freedman Guest

    Oz Springs wrote:
    > I have received a document which is choc-a-block with linked email
    > addresses which make it hard for me to copy and paste. I don¹t need
    > the links at all.
    >
    > I have created a macro which goes from one field to the next to
    > remove the link, and the procedure is semi manual, but I am wondering
    > if there is a better way of doing this. Is there a way of telling all
    > the links to go away via a macro?
    >
    > Thanks for any help
    >
    > Oz


    Hi Oz,

    If the hyperlinks are the only fields in the document, or if you don't care
    about the other fields, you can do it in the GUI with two keystrokes.

    Ctrl+A -- Select all
    Ctrl+Shift+F9 -- Unlink fields

    This converts all fields to plain text of their displayed results.

    If there are other fields that need to remain as fields, use this macro to
    unlink only the hyperlinks:

    Sub UnlinkHyperlinks()
    Dim nHL As Long
    For nHL = 1 To ActiveDocument.Hyperlinks.Count
    ActiveDocument.Hyperlinks(1).Delete
    Next nHL
    End Sub

    Two notes:
    - The .Delete method in VBA does the same as Unlink in the GUI -- it will
    leave the display text in place. To remove the entire thing, you need to do
    ..Hyperlinks(1).Range.Delete.
    - As each hyperlink is deleted, the next one becomes .Hyperlinks(1). This
    technique is needed because the Hyperlinks collection doesn't work properly
    in a For Each loop in which the number of hyperlinks is being changed by
    ..Delete or .Add.

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP
     
    Jay Freedman, Jan 14, 2005
    #4
  5. Oz Springs

    Oz Springs Guest

    Hi Jay
    Thanks for this. I¹ll have to check that I haven¹t replaced Command+Shift+F9
    with something else (or if this is a shortcut on a Mac). It will be handy to
    know when to convert all fields - instantly.

    I¹ll test out the other macro on my document. The one which Jonathan sent me
    worked instantly, even quicker than removing one hyperlink with my old
    method.

    Truly amazed.


    Oz


    On 14/1/05 15:40, in article OmtoX9k#, "Jay
    Freedman" <> wrote:

    > Oz Springs wrote:
    >> I have received a document which is choc-a-block with linked email
    >> addresses which make it hard for me to copy and paste. I don¹t need
    >> the links at all.
    >>
    >> I have created a macro which goes from one field to the next to
    >> remove the link, and the procedure is semi manual, but I am wondering
    >> if there is a better way of doing this. Is there a way of telling all
    >> the links to go away via a macro?
    >>
    >> Thanks for any help
    >>
    >> Oz

    >
    > Hi Oz,
    >
    > If the hyperlinks are the only fields in the document, or if you don't care
    > about the other fields, you can do it in the GUI with two keystrokes.
    >
    > Ctrl+A -- Select all
    > Ctrl+Shift+F9 -- Unlink fields
    >
    > This converts all fields to plain text of their displayed results.
    >
    > If there are other fields that need to remain as fields, use this macro to
    > unlink only the hyperlinks:
    >
    > Sub UnlinkHyperlinks()
    > Dim nHL As Long
    > For nHL = 1 To ActiveDocument.Hyperlinks.Count
    > ActiveDocument.Hyperlinks(1).Delete
    > Next nHL
    > End Sub
    >
    > Two notes:
    > - The .Delete method in VBA does the same as Unlink in the GUI -- it will
    > leave the display text in place. To remove the entire thing, you need to do
    > .Hyperlinks(1).Range.Delete.
    >
    > - As each hyperlink is deleted, the next one becomes .Hyperlinks(1). This
    > technique is needed because the Hyperlinks collection doesn't work properly
    > in a For Each loop in which the number of hyperlinks is being changed by
    > .Delete or .Add.
    >
     
    Oz Springs, Jan 14, 2005
    #5
  6. Oz Springs

    Jay Freedman Guest

    Hi Oz,

    Jonathan's macro and mine work the same way. The difference is just in the
    way we expressed the names of the hyperlinks in order to delete them.

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP

    Oz Springs wrote:
    > Hi Jay
    > Thanks for this. I¹ll have to check that I haven¹t replaced
    > Command+Shift+F9 with something else (or if this is a shortcut on a
    > Mac). It will be handy to know when to convert all fields - instantly.
    >
    > I¹ll test out the other macro on my document. The one which Jonathan
    > sent me worked instantly, even quicker than removing one hyperlink
    > with my old method.
    >
    > Truly amazed.
    >
    >
    > Oz
    >
    >
    > On 14/1/05 15:40, in article OmtoX9k#,
    > "Jay Freedman" <> wrote:
    >
    >> Oz Springs wrote:
    >>> I have received a document which is choc-a-block with linked email
    >>> addresses which make it hard for me to copy and paste. I don¹t need
    >>> the links at all.
    >>>
    >>> I have created a macro which goes from one field to the next to
    >>> remove the link, and the procedure is semi manual, but I am
    >>> wondering if there is a better way of doing this. Is there a way of
    >>> telling all the links to go away via a macro?
    >>>
    >>> Thanks for any help
    >>>
    >>> Oz

    >>
    >> Hi Oz,
    >>
    >> If the hyperlinks are the only fields in the document, or if you
    >> don't care about the other fields, you can do it in the GUI with two
    >> keystrokes.
    >>
    >> Ctrl+A -- Select all
    >> Ctrl+Shift+F9 -- Unlink fields
    >>
    >> This converts all fields to plain text of their displayed results.
    >>
    >> If there are other fields that need to remain as fields, use this
    >> macro to unlink only the hyperlinks:
    >>
    >> Sub UnlinkHyperlinks()
    >> Dim nHL As Long
    >> For nHL = 1 To ActiveDocument.Hyperlinks.Count
    >> ActiveDocument.Hyperlinks(1).Delete
    >> Next nHL
    >> End Sub
    >>
    >> Two notes:
    >> - The .Delete method in VBA does the same as Unlink in the GUI -- it
    >> will leave the display text in place. To remove the entire thing,
    >> you need to do .Hyperlinks(1).Range.Delete.
    >>
    >> - As each hyperlink is deleted, the next one becomes .Hyperlinks(1).
    >> This technique is needed because the Hyperlinks collection doesn't
    >> work properly in a For Each loop in which the number of hyperlinks
    >> is being changed by .Delete or .Add.
     
    Jay Freedman, Jan 14, 2005
    #6
  7. Oz Springs

    Guest

    On Friday, January 14, 2005 10:20:00 AM UTC-5, Oz Springs wrote:
    > I have received a document which is choc-a-block with linked email addresses
    > which make it hard for me to copy and paste. I don¹t need the links at all.
    >
    > I have created a macro which goes from one field to the next to remove the
    > link, and the procedure is semi manual, but I am wondering if there is a
    > better way of doing this. Is there a way of telling all the links to go away
    > via a macro?
    >
    > Thanks for any help
    >
    >
    >
    >
    > Oz


    CTL SHIFT F9 DOES THE TRICK - BEEN NEEDING THIS ONE FOR YEARS - THANKS SO MUCH!
     
    , Oct 26, 2013
    #7
  8. Oz Springs

    Stefan Blom Guest

    But note that Ctrl+Shift+F9 unlinks *all* fields, not just hyperlinks.

    --
    Stefan Blom
    Microsoft Word MVP




    <> skrev i meddelandet
    news:...
    > On Friday, January 14, 2005 10:20:00 AM UTC-5, Oz Springs wrote:
    >> I have received a document which is choc-a-block with linked email
    >> addresses
    >> which make it hard for me to copy and paste. I don¹t need the links at
    >> all.
    >>
    >> I have created a macro which goes from one field to the next to remove
    >> the
    >> link, and the procedure is semi manual, but I am wondering if there is a
    >> better way of doing this. Is there a way of telling all the links to go
    >> away
    >> via a macro?
    >>
    >> Thanks for any help
    >>
    >>
    >>
    >>
    >> Oz

    >
    > CTL SHIFT F9 DOES THE TRICK - BEEN NEEDING THIS ONE FOR YEARS - THANKS SO
    > MUCH!
     
    Stefan Blom, Nov 1, 2013
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.