J
JohnatSydney
Hi Folks - real beginner here with VBA in word, surrounded by technophobes!
Am trying to do a protected form letter. Users enter details in form fields
which populate through the letter using Cross references. There is one
paragraph that I need to insert/remove based on the user checking a checkbox.
(Checked = include the text, unchecked = exclude). My code is below, but I
get a 'Runtime Error 5941 - The requested member of the collection does not
exist.'
I know this is something simple I've done by not structuring the code
correctly...but can't seem to fix it.
Can anyone offer any advice?
- QualityCheck is the Formfield(Checkbox) Name
- QualityWords is the bookbark containing the hidden text.
If the document is password protected, so I need to unprotect to unhide the
text and re-protect again after it's run?
Sub UnhideQualityText()
Dim QualityCheck As String
If FormFields(QualityCheck).CheckBox.Value = False Then
ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = True
Else
ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = False
End If
End Sub
Appreciate any advice.....
Thanks,
John.
Am trying to do a protected form letter. Users enter details in form fields
which populate through the letter using Cross references. There is one
paragraph that I need to insert/remove based on the user checking a checkbox.
(Checked = include the text, unchecked = exclude). My code is below, but I
get a 'Runtime Error 5941 - The requested member of the collection does not
exist.'
I know this is something simple I've done by not structuring the code
correctly...but can't seem to fix it.
Can anyone offer any advice?
- QualityCheck is the Formfield(Checkbox) Name
- QualityWords is the bookbark containing the hidden text.
If the document is password protected, so I need to unprotect to unhide the
text and re-protect again after it's run?
Sub UnhideQualityText()
Dim QualityCheck As String
If FormFields(QualityCheck).CheckBox.Value = False Then
ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = True
Else
ActiveDocument.Bookmarks("QualityWords").Range.Font.Hidden = False
End If
End Sub
Appreciate any advice.....
Thanks,
John.