none
word 2010 command button works only in template but not in document? RRS feed

  • Question

  • Hi all,

    I made a Word 2010 template (mytemplate.dot).
    In that template I made 2 text templates one contains a button (cmdDublicate)
    I entered code (this document) to respond to the click event of the button:

    public sub cmdDublicate_Click()
       msgbox "button hit", vbokonly
    end sub

    Now, when I open the template file (.dot) and insert my texttemplate, and clicking the butten -> the msgbox shows.
    When I open a document based on my template, insert the text template (with vba) and clicking the button -> nothing happens
    (Does not make a difference if document is protected or not)

    ???
    Any help is highly appreciated.
    TIA acki4711




    • Edited by acki4711 Wednesday, November 5, 2014 3:27 PM
    Wednesday, November 5, 2014 3:01 PM

All replies

  • I did have problems getting buttons to work the way I wanted with protections turned on for the full document.  I did not start with a .dot template.

    What I have done is to create separate sections for protected and unprotected parts of the document.  When you turn protection on (Developer tab => Protect section => Restrict Editing button), you can select which sections to protect (unprotect the section containing [just] the button ).  This allowed me to embed other documents into my document in that section.

    Thursday, January 8, 2015 10:18 PM