UserForm with checkboxes that hide/show bookmarked text in document
Hi,
I am very new to UserForms (control fields, VBA, etc.)
I have created a UserForm for a document with a number of text fields and then three checkboxes. The intention of the three checkboxes is to link each one to different bookmarked text within the document. The text needs to be shown/hidden depending on whether or not the checkbox is checked.
My userform has a 'submit' button. I have got the code for filling the text fields and it's working great. I'm stuck on how to structure the If statements. Below is a copy of my code for the 'submit' button on my userform.
Private Sub SubmitButton_Click()
Dim Participant As Range
Set Participant = ActiveDocument.Bookmarks("Participant").Range
Participant.Text = Me.ParticipantName.Value
Dim DateofBirth As Range
Set DateofBirth = ActiveDocument.Bookmarks("DateofBirth").Range
DateofBirth.Text = Me.DOBText.Value
Dim NDISnumber As Range
Set NDISnumber = ActiveDocument.Bookmarks("NDISnumber").Range
NDISnumber.Text = Me.NDISText.Value
Dim ClientNominee As Range
Set ClientNominee = ActiveDocument.Bookmarks("ClientNominee").Range
ClientNominee.Text = Me.ClientText.Value
Dim EffectiveStartDate As Range
Set EffectiveStartDate = ActiveDocument.Bookmarks("EffectiveStartDate").Ran ge
EffectiveStartDate.Text = Me.EffectiveText.Value
Dim EffectiveEndDate As Range
Set EffectiveEndDate = ActiveDocument.Bookmarks("EffectiveEndDate").Range
EffectiveEndDate.Text = Me.UntilText.Value
If ContinenceCB Then ActiveDocument.Bookmarks("ContinenceCost") = True
Else: ActiveDocument.Bookmarks("ContinenceCost") = True
Me.Repaint
UserForm1.Hide
I know that the If statement above is incorrect. I've attached a word document that better explains what I need to show in the completed document - based on checkbox selection.
Any help with this is greatly appreciated.
PS (Sorry if the If statement is total rubish. I'm quite confused at the moment.)
|