Results 1 to 6 of 6

Thread: How to Replace

  1. #1
    Harold
    Guest

    How to Replace

    My first post. I use Word 2000 original.
    I asked this on Microsoft.Public.Word.Pagelayout. No one could give me an answer.
    How do I Replace "o Top" with "| Top" - where Top is a Hyperlink?
    I can give a lot more detail but that seems to confuse some people. Please verify the procedure. Thank you. Harold

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: How to Replace

    Hi Harold,

    More detail would probably help - it's hard to glean what you're trying to do.

    Gary

  3. #3
    Harold
    Guest

    Re: How to Replace

    Okay, Gary, here is some more detail. (No quotes actually used.)
    Put "o Top" into Word and right click on Top and create a hyperlink. Take the top one off the list--it doesn't matter.

    Now, the task is to Replace the o with |. But you don't want to change all of the o's, just the one in front of the Hyperlink Top. (100x.)

    One could reasonably expect that if you copy "o Top" and paste it into the Find what: box and paste it into the Replace with: box also, then delete the o and type a | in its place, you would have a valid Replace setup.

    Not so. Word cannot find the "T" so it returns 0 as the number of replacements made. "What's This ?" finds the o and the p but not the T--in the Word document.

    I'll restate my question:

    How do I Replace "o Top" with "| Top" - where Top is a Hyperlink?

    I really don't know how to ask this question in a more simplistic form.

    I know what doesn't work. I would like to know what will work. I suspect (now) that it has to do with the hyperlink/field.
    ------
    If someone thinks the answer is to copy "o Top" and paste it into the Find What box" they are wrong because I have tried it a dozen times and ways and the POINT OF THE POST is, it DOES NOT WORK. I am WAY PAST this simple of an answer. There is something more that has to be done, or is this a bug in Word?

    HTH. Harold

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Massachusetts
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Replace

    I set up a sample, and I can see the difficulty you are having, there seems to be no good way to search and replace a field including the display text for a hyperlink. I did find a way around it, through a macro. It is rather basic, but it does the job, and can be enhanced to your needs.

    <pre>Dim hlink As Hyperlink
    For Each hlink In Documents(1).Hyperlinks
    If hlink.TextToDisplay = "top" Then
    hlink.Range.Select
    Selection.MoveLeft Unit:=wdCharacter, Count:=2
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    If Selection.Text = "o" Or Selection.Text = "O" Then Selection.Text = "|"
    End If
    Next hlink</pre>


    Please note the "Top" and the "o" are case sensitive.

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Eugene, Oregon, USA
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Replace

    If you don't want to use VBA, try the following:
    (1) Somewhere in your word, copy the | Top (with the hyperlink) to the clipboard
    (2) Show all field codes (Alt-F9)
    (3) Search for 'o ^? HYPERLINK' ("^?" is the wildcard for any character) and replace with "^c" (clipboard contents)

  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 Replace (hyperlinks)

    This is indeed really weird.

    If I create this paragraph:

Posting Permissions

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