Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2013, 11:59 AM
Drizz Drizz is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office 2010 64bit
Novice
Auto message box on open (when using template)
 
Join Date: Apr 2013
Posts: 4
Drizz is on a distinguished road
Default Auto message box on open (when using template)

Help friends...



I figured out how to create a macro to have an informational message box pop up when you open up my word doc, however this particular doc is a template, and so it only works when you right click and choose open, vs if you were to double click to open up the actual template like normal, of which I have multiple boxes pop up to automatically fill in fields throughout the document. (Probably confusing)...

So my question is, how do I get an auto message to pop up on a template document BEFORE the auto field questions come up on a normal double click to open the doc?
Reply With Quote
  #2  
Old 04-17-2013, 01:41 AM
OTPM OTPM is offline Auto message box on open (when using template) Windows 7 32bit Auto message box on open (when using template) Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
Sounds like you need an AutoExec Macro not an AutoOpen.
AutoExec macros run before a document is opened whereas AutoOpen runs when a document is opened.
Have a look at this link:
http://support.microsoft.com/kb/286310
Good luck.
Tony
Reply With Quote
  #3  
Old 04-18-2013, 10:10 AM
Drizz Drizz is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office 2010 64bit
Novice
Auto message box on open (when using template)
 
Join Date: Apr 2013
Posts: 4
Drizz is on a distinguished road
Default

Oh ok I hear ya. So I had this:

'-------- AUTOOPEN ---------------
Sub AutoOpen() 'runs when document is opened
'This name "AutoOpen" is a Visual Basic reserved name for launching
'code when a Word document is opened.
'AutoOpen works in Word 'Auto_Open works in Excel
MsgBox "Ensure that you get Manager authorization", vbOKOnly + vbInformation, "NOTE"
End Sub

Do you have any idea how I edit all that to what I need?
Reply With Quote
  #4  
Old 04-23-2013, 12:41 AM
OTPM OTPM is offline Auto message box on open (when using template) Windows 7 32bit Auto message box on open (when using template) Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi Drizz
Sorry for the late response as I have ben offline for a few days. I will have a look at your issue today and get back to you.
Tony
Reply With Quote
  #5  
Old 04-23-2013, 12:56 AM
OTPM OTPM is offline Auto message box on open (when using template) Windows 7 32bit Auto message box on open (when using template) Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi Drizz

Follow these steps:
1. Open your Normal.dotm template (NOT a document).
2. Create a Macro in a Module as follows:

Sub AutoExec() 'runs when document is opened
'This name "AutoExec" is a Visual Basic reserved name for launching
'code when a Word is opened.
MsgBox "Ensure that you get Manager authorization", vbOKOnly + vbInformation, "NOTE"
End Sub

3. Save your template and close it.
4. Open Word in the normal manner and the AutoExec Macro will run BEFORE any document is opened.

Bear in mind that this will only work on your version of the Normal.dotm template if it is stored locally. If you are using a networked version of the Template then create the macro in that copy of the template. If you want it to work on multiple machines then you must do the same for each machine.
Good luck.
Come back to the forum if you need further help.
Good luck.
Tony

Last edited by OTPM; 04-23-2013 at 06:47 AM.
Reply With Quote
  #6  
Old 04-23-2013, 03:25 PM
fumei fumei is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

I am a little confused. Are you USING the template to create a new document? If you are, then a message in Document_New will fire before any field questions.

"come up on a normal double click to open the doc"

A double click does NOT open a template file.
Reply With Quote
  #7  
Old 04-24-2013, 08:39 AM
Drizz Drizz is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office 2010 64bit
Novice
Auto message box on open (when using template)
 
Join Date: Apr 2013
Posts: 4
Drizz is on a distinguished road
Default

Tony, that actually worked great until I realized it made it to where when I opened even a blank doc it would pop up, vs just for that template. I looked and saw that when I create the macro, I can choose "all documents and templates" or just my current template, but when I choose that option, it doesn't work at all. From what I can tell this is a .dotx template

Fumei, this is a template that has fields pop up to fill out and then when you are finished, it creates a new document for you to save where you want it. I'm not sure what you mean by "then a message in Document_New"... ???
Reply With Quote
  #8  
Old 04-24-2013, 11:41 AM
fumei fumei is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Please describe EXACTLY the steps that happen.

Are you saying you double click on a template, you get a userform with fields to fill in...and THEN a new document is created.

If you have ANY action happening before a document is visibly created then that code is in Document_New. That is, if the code is in the template.

It seems that there is a bit of confusion between code in Normal, and code that may be in the template.

BTW: you definitely are actioning code that is in Normal if the actions occur with all documents.
Reply With Quote
  #9  
Old 04-24-2013, 11:59 AM
fumei fumei is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Quote:
I figured out how to create a macro to have an informational message box pop up when you open up my word doc, however this particular doc is a template, and so it only works when you right click and choose open, vs if you were to double click to open up the actual template like normal, of which I have multiple boxes pop up to automatically fill in fields throughout the document. (Probably confusing)...
Yes it is a little confusing. First of all - "so it only works when you right click and choose open" - DON"T DO THIS. It goes against the whole purpose of a template. Users should not open template files themselves.

Document_New is the vehicle by which a template (a dotm) performs actions before presenting a newly created document. That most definitely includes giving the user fields to fill out. Then, when the user is finished, the new document is presented with (I assume) the data from the filled in fields.

IMO, it is rare that AutoOpen, or AutoNew, or even AutoExec are the way to go. That is very old school.
Reply With Quote
  #10  
Old 04-24-2013, 01:18 PM
Drizz Drizz is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office 2010 64bit
Novice
Auto message box on open (when using template)
 
Join Date: Apr 2013
Posts: 4
Drizz is on a distinguished road
Default

Hi fumei,
I don't have anyone right click to open the template, as obviously that defeats the purpose. I only meant to say that it only worked when I did that and was why I needed autoexec vs autoopen.

Anyhow, this is a template that someone would double click on (or in this case single click, as there is a link on our intranet that they click and a dialog box prompts them to open the template). Then, a field window pops up where they enter information, they click ok, then another field pops up where they enter more, etc etc for several pieces of information that fill in throughout the document, then they can save the new doc anywhere (so yes, it creates a new doc)

I am needing a message box to pop up when they open the template and BEFORE the fields pop up because if they don't meet the requirements in the message box, they are advised to not use the template at all.

P.S. I am VERY green at this side of word, so don't be afraid to speak in stupid people terms and tell me what to do step by step ;-) That being said, is there a problem that this is saving as a dotx vs dotm? I don't know what's new/old as I never use macros etc etc so talk dumb and if nothing can be done, let me know.
Reply With Quote
  #11  
Old 04-24-2013, 04:21 PM
fumei fumei is offline Auto message box on open (when using template) Windows 7 64bit Auto message box on open (when using template) Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

I will say it again, they are not opening the template. They are (at least I think that is what you are saying) calling the template.

I have no idea what you mean by "field window".

A userform is a separate kind-of dialog that is used to gather user information.

" why I needed autoexec vs autoopen. "

I do not think you need either.

"they are advised to not use the template at all."

So they start to use the template...and then are frozen out of it? Fair enough, but you still do not need AutoExec, or AutoOpen. What are the requirements (and how are these determined) that decide whether to proceed further?

In any case, here is a simple example of what I am talking about.

You have a dot file (the template). It has however many userforms you need (for the fields to be filled in). The FIRST userform is the one that decides to go further, or not.

In the ThisDocument module, on Dpcument_New - the template is called, the first userform is shown.

Code:
Option Explicit
Private Sub Document_New()
UserForm1.Show
End Sub
In this simple example, I have a textbox and a commandbutton. Here is the code for the commandbutton.

Code:
Option Explicit
Private Sub CommandButton1_Click()
If TextBox1.Text <> "yadda" Then
Msgbox "Requirements not met.  Template will close."
   ActiveDocument.Close
   Unload Me
Else
   ' show the other "fields"
End If
End Sub
So, when the button is clicked, if the textbox is NOT "yadda" - these are your requirements - the ActiveDocument is closed, and the userform unload.

That means, if the requirement is not met (in this case the text is not "yadda"), there is a message stating requirements not met, the new document closes (never actually shown), the userform closes...and things stop.

If the requirements ARE met - the Else of the IF statement - you proceed with the other field fillin stuff in the other userforms.

No AutoExec. No AutoOpen.
Reply With Quote
  #12  
Old 04-24-2013, 08:40 PM
Charles Kenyon Charles Kenyon is offline Auto message box on open (when using template) Windows Vista Auto message box on open (when using template) Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You want an AutoNew macro in the template or Document_New.

AutoOpen - fires when the file holding the macro is opened.
AutoExec - fires when the file holding the macro is loaded as a global template or Add-In.
AutoNew - fires when a new document is created based on the template.

Note if you put an AutoNew or AutoOpen or Document_New or Document_Open procedure in a global template, including normal.dotm, it will act in all documents and templates!
Reply With Quote
  #13  
Old 04-25-2013, 02:37 AM
OTPM OTPM is offline Auto message box on open (when using template) Windows 7 32bit Auto message box on open (when using template) Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi Drizz
What you need to do is ceate a specific template and follow the instructions I gave you. This will then only apply to documents created to that specific template.
Hope that helps.
Tony
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Message from template not saving nigh Outlook 0 01-11-2012 03:11 AM
Auto message box on open (when using template) Auto reply when receiving a specific message Emerogork Outlook 2 09-06-2011 06:35 PM
30 seconds to open an e-mail message Emerogork Office 0 07-21-2011 08:49 AM
Pop Up Message on Open Emma Samm Word 0 12-20-2010 02:38 PM
Can't Copy and Paste until new message is open tabletop Outlook 0 12-04-2009 11:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:35 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