ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autorun (https://www.excelbanter.com/excel-programming/390695-autorun.html)

EmilH

Autorun
 
Hi.

How can I make my code run as soon as the .xls document is opened?

Thanks in advance.
EmilH.



OssieMac

Autorun
 
2 ways. One is with and event. See Chip Pearsons site for more info.
http://www.cpearson.com/excel/events.htm

The very simple way is to name the procedure as this:-

Sub Auto_Open() and it will run automatically evary time you open the
workbook.

Sub Auto_Close() runs on closing the workbook.

Regards,

OssieMac

"EmilH" wrote:

Hi.

How can I make my code run as soon as the .xls document is opened?

Thanks in advance.
EmilH.




Norman Jones

Autorun
 
Hi E,

Try something like:

'=============
Private Sub Workbook_Open()
Call MyMacro
End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



"EmilH" wrote in message
...
Hi.

How can I make my code run as soon as the .xls document is opened?

Thanks in advance.
EmilH.




blackbox via OfficeKB.com

Autorun
 
Don't know if this is the best way possible but it's worked for me.

In the VB editor select This Workbook in the VBA Project list, then in the
project window change (General) to Workbook. It should give the following

Private Sub Workbook_Open()

End Sub

now insert location.macro name

Private Sub Workbook_Open()
Module1.mymacro
End Sub

--
Message posted via http://www.officekb.com


EmilH

Autorun
 
Thanks a lot!

"Norman Jones" wrote in message
...
Hi E,

Try something like:

'=============
Private Sub Workbook_Open()
Call MyMacro
End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



"EmilH" wrote in message
...
Hi.

How can I make my code run as soon as the .xls document is opened?

Thanks in advance.
EmilH.






EmilH

Autorun
 
Thanks a lot!

"blackbox via OfficeKB.com" <u20390@uwe wrote in message
news:733bf3f2ae14e@uwe...
Don't know if this is the best way possible but it's worked for me.

In the VB editor select This Workbook in the VBA Project list, then in the
project window change (General) to Workbook. It should give the following

Private Sub Workbook_Open()

End Sub

now insert location.macro name

Private Sub Workbook_Open()
Module1.mymacro
End Sub

--
Message posted via http://www.officekb.com





EmilH

Autorun
 
Thanks a lot!

Just a little note: Auto_Open() didn't work but Workbook_Open() did.

"OssieMac" wrote in message
...
2 ways. One is with and event. See Chip Pearsons site for more info.
http://www.cpearson.com/excel/events.htm

The very simple way is to name the procedure as this:-

Sub Auto_Open() and it will run automatically evary time you open the
workbook.

Sub Auto_Close() runs on closing the workbook.

Regards,

OssieMac

"EmilH" wrote:

Hi.

How can I make my code run as soon as the .xls document is opened?

Thanks in advance.
EmilH.







All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com