Reflect Checkboxresult to another checkbox in a protected form

M

Maria@Simonsoft

Hi all,

I have tried to build a macro that aims to from a check list with checkboxes
automaticly reflect the result. I like to when one checkbox is checked
another is checked and reverse. See the code so far below.

I have two problems to solve:
1. I do not get this to work "automatically" when the form is locked, or I
do get the check but not the uncheck of the checkbox. Does anybody know how
to do this?

2. I have tested this on 1 checkbox with bookmark "Check 1" with "Recheck1"
as the reflection Checkbox
I have 52 others with bookmarks check1. Is there a way of writing a macro
without having to list all 52 bookmarks?

Thanks in advance
/Maria

ub ExitCheck()
With ActiveDocument
If .FormFields("Check1").CheckBox.Value Then
.FormFields("Recheck1").CheckBox.Value = True

Else
.FormFields("Recheck1").CheckBox.Value = False

End If
End With
End Sub
 
G

Greg Maxey

Your code seems to work here. You are exiting the the formfield in order to
execute the OnExit macro correct?

Provided your 52 pairs are bookmarked Check1 - Recheck1
Check52 -
Recheck52
Then you should be able to do something like this:

Sub ExitCheck()
Dim pStr As String
With ActiveDocument
pStr = Mid(Selection.FormFields(1).Name, 6,
Len(Selection.FormFields(1).Name) - 5)
If .FormFields("Check" & pStr).CheckBox.Value Then
.FormFields("Recheck" & pStr).CheckBox.Value = True
Else
.FormFields("Recheck" & pStr).CheckBox.Value = False
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top