AutoOpen Macro Word

Hello ,

I have a requirement to Auto run Macro when we open any word document. For that purpose i have created .Dotm template with AutoOpen Macro. Problem is it doesn't execute. When i add the AutoOpen macro in Normal file it works perfectly.

We don't want to add the AutoOpen code in Normal.dotm file. How can we achieve the same requirement using different Template file? We should be able to add AutoOpen macro in file so that we can add this template in startup folder of word.

Can't We create a different template file and add AutoOpen Macro in that file?

Please Help.

August 14th, 2014 11:42am

I haven't tried it in Word, but could you add the DOTM to the Templates & Add-ins of Word?  I don't see why it wouldn't work, give it a shot.

If you're on Office 2010 or 2013, it's File->Options->Addins, then Change "Manage" to "Word Add-ins" and hit Go, then add your DOTM and restart Word.

Free Windows Admin Tool Kit Click here and download it now
August 14th, 2014 1:34pm

Your template with the AutoOpen macro will only work with documents attached to that template. If they're still attached to Normal.dotm, the macro in your other template will never be referenced.
August 14th, 2014 1:45pm

A solution would be a VSTO add-in and you would use the Document_Open routine... its execute every time a document is opened. Your add-in would load load at the start-up of Word.

Here is link to explore about managed add-ins using VSTO. http://msdn.microsoft.com/en-us/office/aa905482.aspx

Free Windows Admin Tool Kit Click here and download it now
August 14th, 2014 9:29pm

Nope. You need a pseudo-Auto macro event handler handling the document open event instead.

 How to create global event procedures similar to AutoOpen, AutoNew and AutoClose, without using Normal.dot

August 17th, 2014 3:12am

Hi Rich,

Thanks for reply. I have created Custom template and I have created macro like below. I have deployed this in the start up folder of the word file.

C:\Users\User\AppData\Roaming\Microsoft\Word\STARTUP

Private Sub Document_Open()
    Set wdApp = Application
     MsgBox "AutoExec66"
End Sub

It doesn't execute. Please Help.

Please help.


  • Edited by Kaushal123 Monday, August 18, 2014 12:29 PM
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2014 11:46am

Hi Charles,

Did you try this? I have created custom template DOTM file and deployed in startup folder of word but it is not working.

August 18th, 2014 11:51am

Hi Kaushal,

I know this thread is a bit old..

But did u ever get the solution for the issue ?

if so can you share what steps did you follow ?

regards,

Free Windows Admin Tool Kit Click here and download it now
April 8th, 2015 10:21am

I know this thread is a bit old..

But did u ever get the solution for the issue ?

if so can you share what steps did you follow ?

         

If you don't want to put auto macros in Normal.dotm you will have to follow the instructions in the article to which Charles Kenyon linked in his reply.

April 8th, 2015 10:44am

Hi Charles,

Did you try this? I have created custom template DOTM file and deployed in startup folder of word but it is not working.

I've used the global auto-open event procedure macro in a global template, yes. That works. Note that the location of the Word Startup Folder can be different on different computers.

AutoOpen does not work in a global template other than normal.dot(m). It works fine in document templates. Again, see the article below.

How to create global event procedures similar to AutoOpen, AutoNew and AutoClose, without using Normal.dot

April 8th, 2015 12:19pm

Hi Charles & Stefan,

Thanks for the reply.

Extending the question on the same lines.. I had one more small doubt.

Lets say if I have to distribute this function/macro to other members of my team; then is distributing the Normal.dot(m) file is the only solution ? or is there a better alternative.

From what I understand if I replace the Normal.dot(m) file then all the macros created by the other members will be lost rite ? 

April 8th, 2015 1:01pm

You should NOT interfere with your users' Normal.dotm templates.

Rather, you should create a new template that contains the code in the article for which Charles provided the link and you should distribute that to be saved in the users' Word Startup folder.

However, exactly what is it that you are trying to achieve?

Free Windows Admin Tool Kit Click here and download it now
April 9th, 2015 6:31am

Hi Doug,

Thanks for the reply.

I have some set of macros/functions which add some menus and features to Word 2010.

I want to distribute this macro to a large group of users. Unfortunately these users are not quiet techie so I can't really ask them to create/update macros scripts on their own.

So i'm trying to find a way to redistribute this macro (which will run when file is opened / created in word 2010 ) without asking the users to do lot of steps (may be just coping a file to some location at max).

I tried creating the .dotm file and adding it in STARTUP folder. But :

1. I was not able to add code to .dotm file after pasting it to STARTUP folder.
2. Even after pre-creating and then pasting file to dotm folder gave me error in 'unreachable' module.

Finally i tried adding my code to Normal.dotm and copying it to other machines and it ran as expected. But i know from my previous experience that Normal.dotm is quiet prone to corruptions (mostly due to users) so i was trying to find a better alternaive.

Any suggestions how can I go about resolving this ?

PS.. sorry for the long reply.. ;)  Jst wanted to make sure i covered everything. 


April 9th, 2015 8:15am

Hi Doug,

Thanks for the reply.

I have some set of macros/functions which add some menus and features to Word 2010.

***


The way to add any of the following to someone else's computer is through a global template (Add-In). You do not need macros that modify the user's system to add any of the following, simply put them in the template:

  1. Macros
  2. Keyboard shortcuts
  3. QAT additions Modifying the QAT and Ribbon in Microsoft Word
  4. Ribbon modifications (through XML, not through the Word Interface) Customize the Ribbon (It doesn't take rocket science)
  5. Building Blocks and AutoText
  6. Styles A Global StyleSheet in Microsoft Word?

Trying to share these modifications through code is asking for trouble. It takes much more programming skill to do it with code than it takes to simply make a template with the features you want and load it as a global template. Professional programmers get it wrong frequently. See Add-Ins in Microsoft Word  and use Google to look for "can't save changes to normal template."

Moving (Sharing) Customizations in Microsoft Word

BTW, I agree wholeheartedly that you do not want to be sharing the normal template, ever. In some instances a custom version of the normal template can be distributed as a part of an installation, but I've seen that messed up more often than not. Once it is there, it should be l
Free Windows Admin Tool Kit Click here and download it now
April 9th, 2015 8:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics