Consulting

Results 1 to 6 of 6

Thread: Remove hyperlinking from only superscript numbers

  1. #1
    VBAX Regular
    Joined
    Mar 2020
    Posts
    73
    Location

    Remove hyperlinking from only superscript numbers

    I am hoping someone can help on this one
    I have a file that has mistakenly got supscript numbers that have been Hyperlinked.
    I can't do the usual Ctrl+Shift+F9 because there are other non superscript Hyperlinks that I need.
    Any help for a macro would be appreciated.
    Is it possible to modify this macro I cam across.

    Dim oField     As Field
    
    For Each oField In ActiveDocument.Fields
        If oField.Type = wdFieldHyperlink Then
            oField.Unlink
        End If
    Next
    
    
    Set oField = Nothing

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,261
    Location
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oField     As Field
      For Each oField In ActiveDocument.Fields
        If oField.Type = wdFieldHyperlink Then
          If oField.Result.Font.Superscript Then
           oField.Unlink
          End If
        End If
      Next
      Set oField = Nothing
    lbl_Exit:
      Exit Sub
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    VBAX Regular
    Joined
    Mar 2020
    Posts
    73
    Location
    Thank you that does the job.

  4. #4
    VBAX Regular
    Joined
    Mar 2020
    Posts
    73
    Location
    Trust me to have some strange ones.
    I have some cases where the superscript is joined to the word and is part of the Hyperlink. Is there a way to retain the link for the normal text part and remove it from the superscript part?
    Judg 13:4210

  5. #5
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,261
    Location
    This might work:

    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oRng As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
    .Style = "Hyperlink"
    .Font.Superscript = True
    While .Execute
    oRng.Style = "Default Paragraph Font"
    oRng.Font.Superscript = True
    oRng.Collapse wdCollapseEnd
    Wend
    End With
    lbl_Exit:
    Exit Sub

    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  6. #6
    VBAX Regular
    Joined
    Mar 2020
    Posts
    73
    Location
    Sorry it did not work.
    Let's call this solved. I don't want to use too much time for you.

    Yea, the problem is more involved. The parsing of the data is making a link that is not correct in any case.

    Good to have the macro for anther case though. Thanks again.

    Jon

Posting Permissions

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