Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2019, 04:48 AM
ukzrsuwy5p ukzrsuwy5p is offline Document_Open does not work in Word 2007 template Windows 7 64bit Document_Open does not work in Word 2007 template Office 2007
Novice
Document_Open does not work in Word 2007 template
 
Join Date: Sep 2019
Posts: 3
ukzrsuwy5p is on a distinguished road
Default Document_Open does not work in Word 2007 template

For employees to work, I need to put some functionality into the Document_Open macro. I want to put this macro in a template (.dot) and place it on the network. Office 2007 is installed on most machines, and I'm testing on it. I create a document, insert the macro code, save it as a template (.dot). I use the following macro as a test:
Code:
Sub Document_Open()
MsgBox "ABC" 
End Sub
Next, I create a document (.doc) and change the document template on my created template. I allow the execution of macros, the macro work. I save and close the document, when I reopen the document and enable macros, our macro does not work. What the problem is I can’t understand. Thank!
Reply With Quote
  #2  
Old 09-25-2019, 03:49 PM
Guessed's Avatar
Guessed Guessed is offline Document_Open does not work in Word 2007 template Windows 10 Document_Open does not work in Word 2007 template Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
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

May be lost in translation.

Template should be saved as (.dotm). Document should be saved as (.docx). Which module is the Document_Open saved in?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 09-26-2019, 12:49 AM
ukzrsuwy5p ukzrsuwy5p is offline Document_Open does not work in Word 2007 template Windows 7 64bit Document_Open does not work in Word 2007 template Office 2007
Novice
Document_Open does not work in Word 2007 template
 
Join Date: Sep 2019
Posts: 3
ukzrsuwy5p is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
May be lost in translation.

Template should be saved as (.dotm). Document should be saved as (.docx). Which module is the Document_Open saved in?
Thank! In the TnisDocument module. Did you manage to repeat my situation? Did the macro work? If the template is .dot and the document .doc will not work?
Reply With Quote
  #4  
Old 09-26-2019, 02:06 AM
gmayor's Avatar
gmayor gmayor is offline Document_Open does not work in Word 2007 template Windows 10 Document_Open does not work in Word 2007 template Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The code should work as long as the document created from the template can still see the template that contains the code. If the document is e.g. sent to a third party, then the document will no longer see the template and the code will not be available.

If you want the code to run when the document is created the macro should be Document_New
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 09-26-2019, 03:28 AM
ukzrsuwy5p ukzrsuwy5p is offline Document_Open does not work in Word 2007 template Windows 7 64bit Document_Open does not work in Word 2007 template Office 2007
Novice
Document_Open does not work in Word 2007 template
 
Join Date: Sep 2019
Posts: 3
ukzrsuwy5p is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
The code should work as long as the document created from the template can still see the template that contains the code. If the document is e.g. sent to a third party, then the document will no longer see the template and the code will not be available.

If you want the code to run when the document is created the macro should be Document_New
The document can see the template, but the macro code does not work. If we open the template and enable macros, then the macro code works. Next, save the template as a document, open the document, enable macros, the macro code does not work.
Reply With Quote
  #6  
Old 09-26-2019, 04:18 AM
gmayor's Avatar
gmayor gmayor is offline Document_Open does not work in Word 2007 template Windows 10 Document_Open does not work in Word 2007 template Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Make the template trusted or put it in a trusted location and try again.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Word 2007 macro to work in Word 2003 Kamaflage Word VBA 1 02-25-2015 11:40 PM
Document_Open does not work in Word 2007 template Why don't grammar/spell checks work in Word 2007? esjayy Word 5 03-12-2014 06:59 PM
Document_Open does not work in Word 2007 template why don't my shortcut links work any more in word 2007? gayb63 Word 3 07-08-2012 10:48 AM
Document_Open does not work in Word 2007 template Word 2007 Font Color Doesn't Work nnicko Word 2 04-16-2010 01:21 PM
Annoying work in Word 2007 CabbageTree Word 2 03-15-2010 01:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:21 AM.


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