Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Execute on File Open

Status
Not open for further replies.

arachnoid

Programmer
Jun 14, 2002
108
US
How can I auto execute a macro when I open a file?

Any insight will be greatly appreciated.
 
Hi
In xl use the workbook open event ie
Code:
Private Sub Workbook_Open()
'code here
End Sub

The same event is available in word. Dunno 'bout ppt and access!

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Thanks for the response, but I guess I am still missing something. That didn't do anything when I added it to the code and re-opened the file.
 
Hey arachnoid - make sure that you are in the "This Workbook" object when you type in the code from Loomah. You can get to this by going to the tools menu, selecting macro and then clicking on Visual Basic editor. On the left, you should see VBA project with the Excel objects listed (Worksheet1, Worksheet2, Worksheet3 and This Workbook - by default).

Double click on This Workbook to open the code window. Then type in Loomah's code or use the object selectors (drop down lists above the code window) to select Workbook from the left drop down list. THis will generate the code stub for the open event.

If you are still having problems or if you have already done this, copy and paste your code in the reply - there may be a problem with the code you are trying to execute.

Hope this helps.

Jay
 
You could also creat a procedure in a standard code module and name it Auto_Open() (not really recommended though) The Workbook_Open event has only been around since '97.



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top