Sub DelFigs()
Dim rng As Range
Dim f As Integer
Dim d As Integer
Set rng = ActiveDocument.Range
Do While True
With rng.Find
.MatchWildcards = True
.Text = "FIG*^13"
If .Execute() Then
f = f + 1
rng.MoveEnd wdCharacter, -1
rng.Select 'show text to be deleted
Select Case MsgBox("Delete?", vbYesNoCancel)
Case vbYes
rng.Delete
d = d + 1
Case vbNo
Case vbCancel
Exit Do
End Select
'start from current position to avoid refinding non-deleted text
rng.Start = rng.End
rng.End = ActiveDocument.Range.End
Else
Exit Do
End If
End With
Loop
MsgBox "Finished. Found Count: " & f & ". Deleted count: " & d
End Sub
Sub ColorCommentsAllGreen()
'170415 based on code by Graham Skan
'modified by crystal
On Error GoTo Proc_Err
Dim nCount As Long
Dim rng As Range
nCount = 0
Set rng = ActiveDocument.Range
Do While True
With rng.Find
.MatchWildcards = True
.Text = "'*^13"
If .Execute() Then
rng.Font.Color = 26112 'dark Green
nCount = nCount + 1
'start from current position to avoid refinding text
rng.Start = rng.End
rng.End = ActiveDocument.Range.End
Else
Exit Do
End If
End With
Loop
MsgBox "Colored " & Format(nCount, "#,##0") & " comments", , "Done"
Proc_Exit:
On Error Resume Next
Set rng = Nothing
Exit Sub
Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ColorCommentsAllGreen"
Resume Proc_Exit
Resume
End Sub
obviously this isn't perfect since I am not checking for a single quote in the code, just assuming it is the start of a comment, which it usually is ...
Wonderful solution. Thanks!