#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Autorun

Hi.

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

Thanks in advance.
EmilH.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autorun.inf Pam Excel Programming 2 October 17th 05 06:56 PM
Autorun a macro Paul Wisken Excel Programming 6 September 7th 05 09:02 AM
Autorun Add-In A.M Excel Programming 2 September 21st 04 04:19 PM
Autorun Macro RK[_3_] Excel Programming 2 February 26th 04 12:15 PM
Autorun a macro Nigel Chapman Excel Programming 1 February 4th 04 01:02 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"