![]() |
#16
|
|||
|
|||
![]()
Hi Paul
I got that code from creating the macro to remove hyperlinks. I will investigate the different code you suggest. The macro now does what I wanted so long as the hyperlinks to the footnotes are removed. However, if there are hyperlinks in the document other than the footnotes, those hyperlinks would also be removed. How could only the hyperlinks to the superscripted footnotes be removed and leave all other hyperlinks? |
#17
|
||||
|
||||
![]()
Your
Code:
Selection.WholeStory Selection.Fields.Unlink Code:
ActiveDocument.Fields.Unlink If you only want to unlink superscripted hyperlinks, you could use: Code:
Sub DemoC() Application.ScreenUpdating = False Dim h As Long With ActiveDocument.Range For h = .Hyperlinks.Count To 1 Step -1 With .Hyperlinks(h).Range If .Font.Superscript = True Then .Fields(1).Unlink End With Next With .Find .ClearFormatting .Replacement.ClearFormatting .Font.Superscript = True .Execute FindText:="[\(\[]*[\)\]]", ReplaceWith:="", MatchWildcards:=True, Format:=False, Forward:=True, Wrap:=wdFindContinue, Replace:=wdReplaceAll End With End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#18
|
|||
|
|||
![]()
The macro also removes brackets and contents that are not superscripted. What have I done wrong?
Code:
Sub RemoveFootnotes() Application.ScreenUpdating = False ActiveDocument.Fields.Unlink ' I think this removes hyperlinks With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Font.Superscript = True .Execute FindText:="[\(\[]*[\)\]]", ReplaceWith:="", MatchWildcards:=True, Format:=False, Forward:=True, Wrap:=wdFindContinue, Replace:=wdReplaceAll End With Application.ScreenUpdating = True End Sub Last edited by macropod; 06-10-2025 at 12:09 AM. Reason: Added code tags for code formatting |
#19
|
||||
|
||||
![]()
That F/R code only affects superscripted content.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
LLLCa947 | Word VBA | 6 | 11-21-2024 01:44 AM |
![]() |
ra_beale | Word VBA | 4 | 09-05-2022 07:09 AM |
![]() |
Swarup | Word | 2 | 07-09-2022 07:42 PM |
![]() |
TheBigBoss | Word VBA | 5 | 06-10-2022 06:14 AM |
![]() |
Swarup | Word | 4 | 07-18-2019 05:51 PM |