user47795 Published in September 19, 2018, 9:09 am
(Office 365 ProPlus version 1701 build 7766.2099, running on Windows 7)
(Edited post, original is lower.)
ActiveX command buttons that occur in a template in a different order than they were created can call the wrong macro, when a file is created from that template.
Exact steps to reproduce:
Create a new document. Save it as a .dotm file. Press enter a couple times to create space at the top of the document. Create an ActiveX Command Button. Double-click it to create procedure, put in MsgBox to ID it. Create a second button ABOVE the first, and its procedure. Now, when the buttons are clicked in the template, they work fine (top one reports 2, bottom reports 1), but when clicked in a file created from the template (double-click file in Explorer window), they are swapped (top reports 1, bottom reports 2).
A very long time ago (earlier version of Word), I created a Word template (.dotm) with buttons that run macros. It used to work fine. I've recently discovered that the buttons now call the wrong macros. If I double-click the template file (creating a new file based on the template), the first button calls the third button's macro and vice-versa. (Middle button, "Fill out forms", works fine.) If I right-click the template and choose Open (open the template itself, not create a new file), the buttons work as designed.
I've boiled the template down to just the 3 buttons and their macros (see photos), and am still seeing the same issue. Clicking "Reset fields", which should call ResetFieldsButton_Click(), instead runs MyPrintButton_Click(). (I get the "Printing..." popup.) What's going on?
vba templates ms-word word-vba
share|improve this question
edited Feb 14 at 18:18
asked Feb 13 at 16:38
Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.
Browse other questions tagged vba templates ms-word word-vba or ask your own question.