#1   Report Post  
Jamie
 
Posts: n/a
Default On Open Macro

I'm working in Word 2002 and have a macro that will run when the form is
open. The following coding works if the user opens the document in Word,
however if they open it through Explorer, the macro does not run.

Private Sub Document_Open()
Dim Msg, Style, Title, Response
Msg = "My message here."
Title = "Shift + Tab Key Error"
Response = MsgBox(Msg, Style, Title)
End Sub

Is there a way to get this to run whether the user opens the document in
Word or Explorer?
---
Jamie
  #2   Report Post  
Shauna Kelly
 
Posts: n/a
Default

Hi Jamie

Is this code in a document or in a template?

If it is in a template, bear in mind that the default action when you
double-click a file name in Windows Explorer is not to open a template, but
to create a new document based on that template. By contrast, the default
action for a document, is to open the document.

The way it's designed to work is as follows:
1. You create a template, and put the code in the template. Code in the
Document_Open event will run whenever a document based on that template is
opened.

2. Users fill in the form by doing File New and selecting your template.
Or, they choose the template using Windows Explorer, and double-click the
name of the template (which will create a new document based on the
template).

If you want code to run whenever anyone creates a new document from the
template, use Private Sub Document_New().

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Jamie" wrote in message
...
I'm working in Word 2002 and have a macro that will run when the form is
open. The following coding works if the user opens the document in Word,
however if they open it through Explorer, the macro does not run.

Private Sub Document_Open()
Dim Msg, Style, Title, Response
Msg = "My message here."
Title = "Shift + Tab Key Error"
Response = MsgBox(Msg, Style, Title)
End Sub

Is there a way to get this to run whether the user opens the document in
Word or Explorer?
---
Jamie



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Run Macro on Open G Lee Microsoft Word Help 5 August 2nd 07 06:28 AM
can macro open file, print and close Word kbgrunt New Users 3 June 17th 05 03:55 PM
How do I use a macro to open a doc as text, without conversion JP Microsoft Word Help 1 May 19th 05 06:00 AM
Form Macro doesn't "stay" when others open the document formhelp Microsoft Word Help 1 March 9th 05 05:04 PM
2000 to 2002 macro and "Could not open macro storage" Art Farrell Mailmerge 1 December 6th 04 12:40 PM


All times are GMT +1. The time now is 05:59 AM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"