Quote:
Originally Posted by macropod
Since you haven't posted any code, or said anything about what you want to do with the found numbers (or anything else you're trying to find in tables), it's impossible to know for sure what the best way is of handling the task.
|
The thing is that it's a very long script. I've tried to combine them, but it didn't always work.
*******************************
So part 1 = Find & Replace the values below in tables, and put them in blue:
Code:
Application.ScreenUpdating = False
Dim aTbl As Table
For Each aTbl In ActiveDocument.Tables
With aTbl.range.Find
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "[$]{1}[0-9,.]{1;}"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "[$\(]{2}[0-9,.]{1;}"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "([0-9]{1;})"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "([0-9,.]{2;})"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "([\(][0-9]{1;}[\)])"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "([\(][0-9,.]{2;}[\)])"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "(^=){1}"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "([\)])([\)])"
.Replacement.Text = "\2"
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End With
'Next
Next aTbl
**********************************
Part 2, If found text in Blue in tables, then Delete
Code:
Application.ScreenUpdating = False
Dim aTbl As Table
For Each aTbl In ActiveDocument.Tables
With aTbl.range.Find
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorBlue
Selection.Find.Replacement.ClearFormatting
'Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "?"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End With
'Next
Next aTbl
***********************************
Please know that I dont have programming skills YET, but I manage with what I know.
I'm sure it could be improved, but since you wanted to see my scripts, here they are
Cendrinne