J
Jeffery B Paarsa
In a Word VBA code I am displaying a Form/Screen with lots of Checkboxes on
the form to the user. I would like to set the value of check boxes on the
word document to the value of check boxes coming from the form/screen by the
user. Here is the code I use:
Calling subroutine:
Private Sub CMDPage4N_Click()
With ActiveDocument
.Unprotect
UpdateCheckBox "SWgtLoss", ChkB01.Value
.Protect wdAllowOnlyFormFields
UserForm1.MultiPage1.Value = MultiPage1.Value + 1
End With
End Sub
Here is the Called Subroutine:
Public Sub UpdateCheckBox(BookmarkToUpdate As String, BoolData As Boolean)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
With ActiveDocument.FormFields(BookmarkToUpdate).CheckBox
.Value = BoolData
End With
End Sub
I turned on the debug on the following line in the calling subroutine:
UpdateCheckBox "SWgtLoss", ChkB01.Value
Having the document open at the back of the debug screen I can see the
related check box field is being set to X but as soon as I come out go to the
following line:
UserForm1.MultiPage1.Value = MultiPage1.Value + 1
my check box tunes into unchecked box and X is being removed. I think I
know I have call by value problem but I have used 3-4 hours to resolve this
problem and keep the X in the box with no success. Any suggestion?
the form to the user. I would like to set the value of check boxes on the
word document to the value of check boxes coming from the form/screen by the
user. Here is the code I use:
Calling subroutine:
Private Sub CMDPage4N_Click()
With ActiveDocument
.Unprotect
UpdateCheckBox "SWgtLoss", ChkB01.Value
.Protect wdAllowOnlyFormFields
UserForm1.MultiPage1.Value = MultiPage1.Value + 1
End With
End Sub
Here is the Called Subroutine:
Public Sub UpdateCheckBox(BookmarkToUpdate As String, BoolData As Boolean)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
With ActiveDocument.FormFields(BookmarkToUpdate).CheckBox
.Value = BoolData
End With
End Sub
I turned on the debug on the following line in the calling subroutine:
UpdateCheckBox "SWgtLoss", ChkB01.Value
Having the document open at the back of the debug screen I can see the
related check box field is being set to X but as soon as I come out go to the
following line:
UserForm1.MultiPage1.Value = MultiPage1.Value + 1
my check box tunes into unchecked box and X is being removed. I think I
know I have call by value problem but I have used 3-4 hours to resolve this
problem and keep the X in the box with no success. Any suggestion?