How does one reference the VALUE of a FORMCHECKBOX bookmark?

G

Guest

I want to use the Checked or Unchecked state of a FORMCHECKBOX to control the
display of text in a template. I can do this using a FORMTEXT or FORMDROPDOWN
field with a bookmark and "Calculate on exit" selected.

With either FORMTEXT or FORMDROPDOWN I can write
{ IF {bookmark} = "X" text1 text2 }
and it works fine, but how do I do this with FORMCHECKBOX?
 
D

Doug Robbins

ActiveDocument.FormFields("Bookmarkname").CheckBox.Value

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Greg Maxey

Robert,

I won't swear to it, but I don't think you can without a bit of VBA. If you
use a DocVariable field instead of the if field for your conditional text,
have the check box "calculate on exit, and run a macro on exit from the
checkbox similar to the following example you should be set:

Sub CheckStat()
If ActiveDocument.FormFields("Check1").Result = True Then
ActiveDocument.Variables("Checkstat").Value = "Checked"
Else
ActiveDocument.Variables("Checkstat").Value = "Unchecked"
End If
End Sub

In place of the IF field use this field: { DOCVARIABLE "CheckStat" }

Variable name, macro name and bookmark names are of course up to you.

HTH
 
G

Greg Maxey

Doug,

What is the difference between:
ActiveDocument.FormFields("Bookmarkname").CheckBox.Value
and:
ActiveDocument.FormFields("Check1").Result

Thanks
 
D

Doug Robbins

Hi Greg,

The former returns either True or False and the latter returns 1 or 0.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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