View Single Post
 
Old 04-13-2021, 07:25 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

It seems to me your first macro could be reduced to:
Code:
Sub Demo1()
Application.ScreenUpdating = False
Dim Tbl As Table
For Each Tbl In ActiveDocument.Tables
  With Tbl.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Replacement.Font.Color = wdColorBlue
    .Format = True
    .Forward = True
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Text = "$[0-9,.]{1;}"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    .Text = "\($[0-9,.]{1;}\)"
    .Execute Replace:=wdReplaceAll
    .Text = "[0-9]{1;}"
    .Replacement.Text = "^&"
    .Execute Replace:=wdReplaceAll
    .Text = "[0-9,.]{2;}"
    .Execute Replace:=wdReplaceAll
    .Text = "\([0-9]{1;}\)"
    .Execute Replace:=wdReplaceAll
    .Text = "\([0-9,.]{2;}\)"
    .Execute Replace:=wdReplaceAll
    .Text = "^="
    .Execute Replace:=wdReplaceAll
    .Text = "\)\)"
    .Replacement.Text = ")"
    .Execute Replace:=wdReplaceAll
  End With
Next Tbl
Application.ScreenUpdating = True
End Sub
Similarly, the second macro could be reduced to:
Code:
Sub Demo2()
Application.ScreenUpdating = False
Dim Tbl As Table
For Each Tbl In ActiveDocument.Tables
  With Tbl.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Font.Color = wdColorBlue
    .Format = True
    .Forward = True
    .Wrap = wdFindStop
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
  End With
Next Tbl
Application.ScreenUpdating = True
End Sub
I see none of the 'it doesn't do it for numbers as a wildcards' issues to which you refer.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote