I'm trying to create a macro to find section breaks and page breaks and then add comments them to separately.
Code: Select all
Sub Test()
Application.ScreenUpdating = False
'Clear Comments
Application.UserName = "Section Breaks Or Page Breaks"
Application.UserInitials = "SBPB"
For Each oCom In ActiveDocument.Comments
If oCom.Initial = "SBPB" Then
oCom.Delete
End If
Next oCom
Const message1 As String = "Page Break!"
With Selection.Find
.ClearFormatting
.Text = "^m"
.MatchWildcards = False
Do While .Execute
ActiveDocument.Comments.Add Range:=Selection.Range, Text:=message1
Loop
End With
Const message2 As String = "Section Break!"
With Selection.Find
.ClearFormatting
.Text = "^b"
.MatchWildcards = False
Do While .Execute
ActiveDocument.Comments.Add Range:=Selection.Range, Text:=message2
Loop
End With
Application.ScreenUpdating = True
End Sub
Thanks!