Enabling Command Button VBA code in Form RRS feed

  • Question

  • I have created a macro-enabled form template in word 2007.

    I have placed two command buttons on the form. clicking on each button calls a function "signdocument" that starts a macro that digitally signs the document using a Topaz lcd signature pad.

    The buttons and code run fine in the template.

    However, once I protect the template and create a new document from it the command buttons are blanked out and the code will not run.

    the code WILL work however if I create a button in the office toolbar.

    However this is a kludge and not what I want.

    I would appreciate any ideas or comments or suggestions. does not have to be a command button,,,it could be any other type of control that would signfiy the user to sign the document.




    Friday, January 27, 2012 6:49 PM


All replies

  • Hi Adam

    What commands did you use to place the button on the document? (We need to know what kind of button this is.)

    What kind of protection are you applying to the template?

    Cindy Meister, VSTO/Word MVP
    Saturday, January 28, 2012 7:11 AM
  • See the article "Using MacroButton fields” at:

    If you want to, you can use and { IncludePicture } field to display a button in the field with a field construction such as

    MACROBUTTON [macroname] { INCLUDEPICTURE "C:\\[path]\\BUTTON.JPG } } 

    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Jawsurgeon Saturday, January 28, 2012 5:31 PM
    Saturday, January 28, 2012 10:05 AM
  • Hi Cindy:

    I enabled the 'developer' tool box

    Added a command button

    Added the code behind the command button to run a function which runs the macro.

    I also tried running the code behind a checkbox...

    the form is run in Protected for forms mode; since I want the user to click on various check boxes and also be able to fill in several combo boxes.

    That is where the issue comes in. ONce the form is protected, no code will run behind the command button or check box.


    Saturday, January 28, 2012 4:19 PM
  • Doug:

    Thanks this worked pefectly.

    subsequently I also found that if I changed the functions to subs (i.e. macros)...the code executed pefectly in the command buttons I placed (including activeX controls); even when the document was protected for 'forms"



    Saturday, January 28, 2012 5:31 PM