Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 04-02-2025, 06:11 PM
gcp gcp is offline VBA Word Macro - remove superscript footnote ref Windows 11 VBA Word Macro - remove superscript footnote ref Office 2021
Novice
VBA Word Macro - remove superscript footnote ref
 
Join Date: Mar 2025
Posts: 17
gcp is on a distinguished road
Default Remove superscript footnote

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?
Reply With Quote
  #17  
Old 04-02-2025, 10:28 PM
macropod's Avatar
macropod macropod is offline VBA Word Macro - remove superscript footnote ref Windows 10 VBA Word Macro - remove superscript footnote ref Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your
Code:
Selection.WholeStory
Selection.Fields.Unlink
gives the same result as
Code:
ActiveDocument.Fields.Unlink
The differences are that the latter code doesn't employ the inefficient selection method or change your current selection.

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]
Reply With Quote
  #18  
Old 06-09-2025, 11:39 PM
gcp gcp is offline VBA Word Macro - remove superscript footnote ref Windows 11 VBA Word Macro - remove superscript footnote ref Office 2021
Novice
VBA Word Macro - remove superscript footnote ref
 
Join Date: Mar 2025
Posts: 17
gcp is on a distinguished road
Default

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
Reply With Quote
  #19  
Old 06-10-2025, 12:10 AM
macropod's Avatar
macropod macropod is offline VBA Word Macro - remove superscript footnote ref Windows 10 VBA Word Macro - remove superscript footnote ref Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That F/R code only affects superscripted content.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Word Macro - remove superscript footnote ref Word Macro for removing parentheses around footnote numbers LLLCa947 Word VBA 6 11-21-2024 01:44 AM
VBA Word Macro - remove superscript footnote ref Convert superscript numbers to auto-footnote markers ra_beale Word VBA 4 09-05-2022 07:09 AM
VBA Word Macro - remove superscript footnote ref How to remove extra space between footnote separator and 1st footnote. No para breaks present. Swarup Word 2 07-09-2022 07:42 PM
VBA Word Macro - remove superscript footnote ref Macro to change font size of Footnote Reference in Footnote Text TheBigBoss Word VBA 5 06-10-2022 06:14 AM
VBA Word Macro - remove superscript footnote ref Footnote reference numbers precede by superscript '(' and follow w/ superscript ')' Swarup Word 4 07-18-2019 05:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft