Option Explicit
Sub CheckIt()
Dim oBMs As Bookmarks
Dim oStr As String
Dim oRng As Word.Range
'ActiveDocument.Unprotect'Activate this line if using a protected Word form
Set oBMs = ActiveDocument.Bookmarks
oStr = Selection.Bookmarks(1).Name
Set oRng = oBMs(oStr).Range
ActiveDocument.AttachedTemplate.AutoTextEntries("Check1").Insert Where:=oRng
oBMs.Add oStr, oRng
oRng.Font.Color = wdColorBlack
'ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True'Activate this line as required.
End Sub
Sub UncheckIt()
Dim oBMs As Bookmarks
Dim oStr As String
Dim oRng As Word.Range
'ActiveDocument.Unprotect'Activate this line if using a protected Word form
Set oBMs = ActiveDocument.Bookmarks
oStr = Selection.Bookmarks(1).Name
Set oRng = oBMs(oStr).Range
ActiveDocument.AttachedTemplate.AutoTextEntries("Check2").Insert Where:=oRng
oBMs.Add oStr, oRng
oRng.Font.Color = wdColorAutomatic
'ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True'Activate this line as required.
End Sub
However, when I click on the boxes, I get a dialogue box that says, "Run-time error '5941': The requested member of the collection does not exist"
So, I click on debug and this is what is highlighted:
ActiveDocument.AttachedTemplate.AutoTextEntries("Check1").Insert Where:=oRng
"Check1" is the name of the bookmark for the check box I am trying to use. Is my error in defining parameters for both checked and unchecked at the same time when I should only be defining for one at a time? Or is the error that I need to change "AutoTextEntries(Check1)" to something else. If so, how am I suppose to know what to change it to?