• How to Replace

    Author
    Topic
    #1768182

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1778013

      Hi Harold,

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

      Gary

      • #1778015

        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

        • #1778018

          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.

          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

          Please note the “Top” and the “o” are case sensitive.

        • #1778021

          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)

        • #1778020

          This is indeed really weird.

          If I create this paragraph:

    Viewing 0 reply threads
    Reply To: How to Replace

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: