Thanks. I tried this, but it's still not working.
Code:
Private Sub CommandButton1111_Click()
Dim Name As String
If Selection.FormFields.Count = 1 Then
Name = Selection.FormFields(1).Name
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then
Name = Selection.Bookmarks(Selection.Bookmarks.Count).Name
End If
MsgBox Name
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
ActiveDocument.Bookmarks(Name).Select
Selection.Font.Color = wdColorRed
Selection.Collapse Direction:=wdCollapseEnd
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
End Sub
I'm getting RunTime error 5941 "The requested member of the collection does not exist." And the line "ActiveDocument.Bookmarks(Name).Select" is Highlighted