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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run macro automatically when file is opened

Status
Not open for further replies.

Lucieann

Technical User
Aug 29, 2003
35
US
I need to figure out how to automatically run a macro when a file is opened. I have tried, but it seems all that is happening is that the file is opening, but no macro is running. Any help would be appreciated.

Thanks!
 
Private Sub Workbook_Open()
Dim s As String
s = MsgBox("this is a open of document", vbOKOnly)
End Sub

Private Sub document_Open()
Dim s As String
s = MsgBox("this is a open of document", vbOKOnly)
End Sub

This assuming that it is either a Excel or Word document you are referring to.

It is advisable to give more details of what you are trying to do whenever posting a question.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Call your macro Auto_Open() if you're using '97 else use the Workbook_Open event
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top