[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do get macro in MS Word to start when document is loaded?

Posted on 2005-04-22
4
Medium Priority
?
288 Views
Last Modified: 2013-12-25
I have written a macro VBA in Microsoft Word. When I open the document that contains the macro, how can I get a macro to run automatically after document has loaded?
0
Comment
Question by:gar7
  • 3
4 Comments
 
LVL 10

Accepted Solution

by:
edwardiii earned 1000 total points
ID: 13847176
Hi, gar7.

If your macro is "Macro1" you could do the following:

1)   Do Alt-F11 when your Word doc is open to display the Microsoft Visual Basic code window.

2)   In the left-hand Project-Normal box expand "Microsoft Word Objects" and double-click "ThisDocument."

3)   On the top-left dropdown of the "Normal - ThisDocument (Code)" window, click "Document."  On the right-hand dropdown click "Open."

4)   In the Private Sub Document-Open() method, enter the following code:

     Call Macro1

0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13847244
Sorry--I'm used to applying code to all Word docs in my library at once.

In step 1 above, replace "left-hand Project-Normal box expand" with "Project window expand Project(Document1) and ".
In step 3 above, replace "Normal - ThisDocument(Code)" with "Document1 - ThisDocument(Code)".

That will only apply this coding to the current Word document, not every one you open as controlled by Normal.
0
 

Author Comment

by:gar7
ID: 13860526
edwardiii - Thabks for the help. You hit it right on the head!!

0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13860572
Glad to have helped:)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question