PDA

View Full Version : [SOLVED:] Remove hyperlinking from only superscript numbers



JPG
01-22-2021, 08:12 AM
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

gmaxey
01-22-2021, 09:03 AM
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

JPG
01-22-2021, 09:28 AM
Thank you that does the job.

JPG
01-22-2021, 09:33 AM
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 (tw://bible.*/?id=7.13.255-0.0.0)

gmaxey
01-22-2021, 09:52 AM
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

JPG
01-22-2021, 10:05 AM
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