Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2025, 09:54 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

This is the code that Co-Pilot wrote for me, that doesn't work. It has elements of Paul's replace that, as a novice, I can follow. As I sat, I am trying to get my head around VBA and I hope that making this work will give me some good tuition.

Sub DeleteSuperscriptText()
Dim rng As Range
Dim startPos As Long
Dim endPos As Long

Set rng = ActiveDocument.Content
With rng.Find
.ClearFormatting
.Font.Superscript = True
.Text = "\(*\)"
.Forward = True
.Wrap = wdFindStop
.Format = True


.MatchWildcards = True

Do While .Execute
If rng.Font.Superscript = True Then
startPos = rng.Start
endPos = rng.End

' Adjust the range to select the characters between "(" and ")"
rng.SetRange startPos + 1, endPos - 1

' Delete the characters
rng.Delete

' Move the cursor to the next non-superscript position
Set rng = ActiveDocument.Range(rng.End, ActiveDocument.Content.End)
If rng.Find.Execute(FindText:="", Forward:=True, Wrap:=wdFindStop) Then
If rng.Font.Superscript = False Then
rng.Collapse wdCollapseStart
Exit Sub
End If
End If
End If
Loop
End With
End Sub
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 08:48 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