Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2015, 08:32 AM
dkohnken dkohnken is offline Help with a Command Button Windows 7 64bit Help with a Command Button Office 2013
Novice
Help with a Command Button
 
Join Date: Mar 2015
Posts: 3
dkohnken is on a distinguished road
Default Help with a Command Button

I have built a Word 2013 form which contains Legacy Controls, ActiveX Controls and the Date Picker from the default controls in the Developer tab.
I am relatively new building forms in Word. I hope this is not too wordy, but I am not sure how to explain it.



This form is for Supervisors and managers to enter information about new Employees. Some of the information, Name, Supervisor name, start date, approving department head and email for department head.

I have added several VBA Macros, one to read the name of the Department Head and get their email from Active Directory. This all works good, even when I open a new document from the template.

I added a button at the bottom of the form to validate all required information, which as a dotm works great. But after saving the dotm file, and open the dotm as a new document the code that I entered in the button's click event is not there. It seems that the code is not being written to the Click event of the new form. If I unprotect the new document and click on the Developer Tab and view the code, All I have is Private Sub Submit_Click() and no code. Listed underneath the new Document in the VBA editor is the original template. Clicking on ThisDocument and viewing the code, I see my Private Sub Submit_Click() with all the code I wrote.

I have gone into the Trust Center and enabled Macros and ActiveX.
I have searched for answers, but found none that work. Am I doing something wrong? Any help would be appreciated. Thank you in advance for all your help.
Reply With Quote
  #2  
Old 03-16-2015, 07:08 PM
gmaxey gmaxey is offline Help with a Command Button Windows 7 32bit Help with a Command Button Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Sounds like your control in the new document is in design mode. What happens if you come out of design mode?

Why are you mixing all of these control types? I would use content controls and a ribbon or QAT command button. ActiveX controls carry a lot of baggage.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 03-16-2015, 08:15 PM
Guessed's Avatar
Guessed Guessed is offline Help with a Command Button Windows 7 32bit Help with a Command Button Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,973
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I suspect that you shouldn't be using the ThisDocument module for your code. In the case of the code sitting in an attached template, ThisDocument refers to the attached template rather than the activedocument.

The Submit_Click code should be sitting in the userform's own module.

If that doesn't solve it, can you post your template?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 03-17-2015, 06:46 AM
gmaxey gmaxey is offline Help with a Command Button Windows 7 32bit Help with a Command Button Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Guessed. It suspect that he is using a ActiveX control (not a Userform) and the command button code has to be in the ThisDocument module.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 03-17-2015, 04:57 PM
Guessed's Avatar
Guessed Guessed is offline Help with a Command Button Windows 7 32bit Help with a Command Button Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,973
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Re-reading the OP, I suspect that your suspicion is correct Greg. :-)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 03-18-2015, 10:13 PM
dkohnken dkohnken is offline Help with a Command Button Windows 7 64bit Help with a Command Button Office 2013
Novice
Help with a Command Button
 
Join Date: Mar 2015
Posts: 3
dkohnken is on a distinguished road
Default

Thank you all for your suggestions. I built a UserForm and added the controls from there. Seems to be working, except I am trying to get a Date Picker into the UserForm. I will update this thread as I continue working on it.

Thank you
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
command button query smalc Word VBA 2 03-16-2015 08:26 PM
Command Button knp11 PowerPoint 2 01-18-2015 01:41 PM
Help with a Command Button PP Command Button wont run on another PC gerris PowerPoint 6 01-12-2015 10:17 AM
Help with a Command Button Command Button to Print Labels Claytocb Excel Programming 1 02-01-2013 12:20 AM
Help with a Command Button Command Button cksm4 Word VBA 7 02-27-2011 08:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft