Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Jul 2008
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to find broken hyperlinks in txt files (Word

    I need a macro, perhaps using a regular expression, to find hyperlinks that are broken or with improper syntax. Expressed another way, I want to find hyprlinks that do not match the following patterns. In the first hyperlink, the only part of the hyperlink that changes from one record to the next is the number 39762. Likewise for the next hyperlink with the number 39764. In these two hyperlinks below, only the number changes from record to record. Everything else in the hyperlink is a constant from one record to the next.

    PREVIOUS

    NEXT

    In this third hyperlink below, the only part of the hyperlink to change from record to record is Rev 21:6

    Everything else in the hyprlink is a constant from one record to the next.

    <U>Rev 21:6</U>

    If a hyperlink does not match the above patterns, I would like the macro to insert three [[[ left brackets so I can find the improper hyperlink after the macro is run.

    Thank you in advance for your help.

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

    Re: Need to find broken hyperlinks in txt files (Word

    Try the macro in the attached zip file (I zipped it because text with embedded HTML code could cause problems).
    Attached Files Attached Files

  3. #3
    Star Lounger
    Join Date
    Jul 2008
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to find broken hyperlinks in txt files (W

    Thank you Hans. I will give this a try and post back in a few hours.

  4. #4
    Star Lounger
    Join Date
    Jul 2008
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to find broken hyperlinks in txt files (W

    Thank you for the help.

    Hans, could you take a look at my comments preceded by the arrows >>>> to make my comments stand out. The hyperlinks below all have some kind of error. I ran the macro on these links. Please see the >>>> comment line.


    <U>Isa 55:1</U>. Compare the <U>Mat 5:6</U></U> The reader of the text should note; <U>Joh 7:37"></U></U>
    note; <U>Rev 21:6</U>
    note.</P>

    And whosoever will, let him take the water of life freely - <U>Rev 21:6</U>Rev 21:6"></U>

    >>>>missed out of place underline tags
    >>>>missed improper "> in a link
    >>>>finds extra spaces in a hyperlink
    >>>>missed doubling of the display part of the link

    <p align="right"><font face="Arial">[[[PREVIOUS NEXT</a></FONT>','NULL');

    >>>>Picks up if extra tag </a> in Next link

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

    Re: Need to find broken hyperlinks in txt files (W

    The macro I wrote performs only simple pattern checking; I don't see an easy way of expanding it to meet your requirements

    It would probably be better to use a regular expression tool for this; the Find feature in Word and the Like operator provide only a fraction of what is possible with regular expressions. However, complicated regular expressions always give me a headache, so I am not the best person to help you with that. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  6. #6
    Star Lounger
    Join Date
    Jul 2008
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to find broken hyperlinks in txt files (W

    OK, thank you Hans, really appreciate what you do.

  7. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Need to find broken hyperlinks in txt files (W

    These sorts of errors are more of a syntax failure than a broken hyperlink (which is more commonly thought of as a valid hyperlink that points to a page that doesn't exist).

    Perhaps an HTML or XML validator would be a better tool to check for these types of errors.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  8. #8
    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: Need to find broken hyperlinks in txt files (W

    You might be able to use Tidy, also known as HTML Tidy. It is integrated into some HTML editors, or you can read more here: http://tidy.sourceforge.net/#binaries.

  9. #9
    Star Lounger
    Join Date
    Jul 2008
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to find broken hyperlinks in txt files (W

    Thank you for the suggestions. The files I am working with are in the 10 to 20 meg. range. I think if I could find a regex statement, I could use that statement to mark all the urls and then extract those to another file, then process from there.

    Thank all of you again. Woody's is a big help to me.

  10. #10
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How would one find text that has a hyperlink assoicated with it (blue underlined text) like in a Word document?

  11. #11
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by Jim Bassett View Post
    How would one find text that has a hyperlink assoicated with it (blue underlined text) like in a Word document?
    Hi Jim,

    I've already given you code to do that for URLs in Post 771669 in the Word forum. That code finds URLs regrdless of whether they're active hyperlinks. Are you looking for code to find only active hyperlinks? What about file, mailto and internal hyperlinks within a document?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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