Word 2003 code question

S

SireCat

I am completely new to VBA for any office product so bear with me please.
What I would like to learn is how to write code to watch for a mouse click
action on a checkbox and then check/uncheck OnMouseClick. Currently I have to
protect the document, click password prompt, and then check the box and
unprotect to continue with my edits.
 
J

Jay Freedman

SireCat said:
I am completely new to VBA for any office product so bear with me
please. What I would like to learn is how to write code to watch for
a mouse click action on a checkbox and then check/uncheck
OnMouseClick. Currently I have to protect the document, click
password prompt, and then check the box and unprotect to continue
with my edits.

Unfortunately, there is no MouseClick event accessible in Word VBA. The real
problem, though, is that you're trying to use a form field (which is active
only in a protected document) in an unprotected document.

One solution is to replace the form field with a different sort of field.
See http://gregmaxey.mvps.org/Add_Toggle_Objects.htm for instructions.

Another solution, although it has enough drawbacks that I wouldn't consider
it, is to use an ActiveX checkbox from the Control Toolbox. See
http://msdn2.microsoft.com/en-us/library/aa140269(office.10).aspx, but pay
special attention to the section titled "Appropriateness for the Task".

A third "solution" is to continue with the form field checkbox; but instead
of protecting/unprotecting the document, just double-click the checkbox to
open its Properties dialog, change the Default Value setting, and close the
dialog.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
S

SireCat

Thanks a bunch Jay for a workaround.

Jay Freedman said:
Unfortunately, there is no MouseClick event accessible in Word VBA. The real
problem, though, is that you're trying to use a form field (which is active
only in a protected document) in an unprotected document.

One solution is to replace the form field with a different sort of field.
See http://gregmaxey.mvps.org/Add_Toggle_Objects.htm for instructions.

Another solution, although it has enough drawbacks that I wouldn't consider
it, is to use an ActiveX checkbox from the Control Toolbox. See
http://msdn2.microsoft.com/en-us/library/aa140269(office.10).aspx, but pay
special attention to the section titled "Appropriateness for the Task".

A third "solution" is to continue with the form field checkbox; but instead
of protecting/unprotecting the document, just double-click the checkbox to
open its Properties dialog, change the Default Value setting, and close the
dialog.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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