View Single Post
 
Old 03-24-2025, 10:43 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Quote:
Originally Posted by gcp View Post
Thanks Paul. I couldn't make that work as "Replace = nothing
where the Find format is specified as superscript" is beyond my abilities.
In any event, my aim is to learn to write VBA macros.
I tested it and it worked for me. Are your parentheses superscripted?

As a macro, the Find/Replace becomes:
Code:
Sub DemoA()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Font.Superscript = True
  .Text = "\(*\)"
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
or even:
Code:
Sub DemoB()
Application.ScreenUpdating = False
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
Avoid generative AI VBA code - it's frequently bug-ridden. Even Word's macro recorder would have done better in this instance.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote