Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Auto_Open vs Open and call macro --priority question

Hi:

I have a spreadsheet called "collector.xls" that contains a macro "auto_open", which is
intended to execute when ever the sheet is opened. I am calling this sheet from another
sheet (opening the sheet in question and then calling a macro in the sheet I just
opened"), as in



Workbooks.Open Filename:="C:\IPT\timesheets\Collector.xls"
Application.Run "Collector.xls!Collectorcheckandmove"

My question is whether the auto-open macro in the collector will execute before the macro
I am calling from the external spreadsheet.

Thanks for he response

John Baker
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Auto_Open vs Open and call macro --priority question

Hi John

Auto_open won't run at all when you open from code. Unless you request it to run like
this:

ActiveWorkbook.RunAutoMacros (xlAutoOpen)

These things are pretty easy to test for yourself with something like

Sub Auto_open()
MsgBox "HI from Auto_open"
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"John Baker" wrote in message
...
Hi:

I have a spreadsheet called "collector.xls" that contains a macro "auto_open", which is
intended to execute when ever the sheet is opened. I am calling this sheet from another
sheet (opening the sheet in question and then calling a macro in the sheet I just
opened"), as in



Workbooks.Open Filename:="C:\IPT\timesheets\Collector.xls"
Application.Run "Collector.xls!Collectorcheckandmove"

My question is whether the auto-open macro in the collector will execute before the

macro
I am calling from the external spreadsheet.

Thanks for he response

John Baker



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Auto_Open vs Open and call macro --priority question

In article ,
John Baker wrote:

Hi:

I have a spreadsheet called "collector.xls" that contains a macro
"auto_open", which is
intended to execute when ever the sheet is opened. I am calling this sheet
from another
sheet (opening the sheet in question and then calling a macro in the sheet I
just
opened"), as in



Workbooks.Open Filename:="C:\IPT\timesheets\Collector.xls"
Application.Run "Collector.xls!Collectorcheckandmove"

My question is whether the auto-open macro in the collector will execute
before the macro
I am calling from the external spreadsheet.



Actually, the auto-open macro won't run at all. Auto-macros will run
if the file is opened directly (via the file menu or from the
Finder), but will not run when opened from code.

To get automacros to run, you need to use


Workbooks.Open Filename:="C:\IPT\timesheets\Collector.xls"
ActiveWorkbook.Autorun xlAutoOpen
Application.Run "Collector.xls!Collectorcheckandmove"

Alternatively, you can run macros on opening (whether from code or
direct) by calling it from, or including it in, the opened
workbook's Workbook_Open() event. Put this in the ThisWorkbook code
module:

Private Sub Workbook_Open()
MyOpenMacro 'or include macro here
End Sub

In general, if opening directly, Auto_Open macros run after all
event macros associated with opening a file, but before your
Application.Run call.

To see the order of firing:

http://cpearson.com/excel/events.htm
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Auto_Open vs Open and call macro --priority question

Just and added comment.
ActiveWorkbook.RunAutoMacros (xlAutoOpen)
really shouldn't have parens around the argument since you are not returning
a value. It doesn't cause a problem here, but could if the argument were an
object.

ActiveWorkbook.RunAutoMacros xlAutoOpen


--
Regards,
Tom Ogilvy


Harald Staff wrote in message
...
Hi John

Auto_open won't run at all when you open from code. Unless you request it

to run like
this:

ActiveWorkbook.RunAutoMacros (xlAutoOpen)

These things are pretty easy to test for yourself with something like

Sub Auto_open()
MsgBox "HI from Auto_open"
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"John Baker" wrote in message
...
Hi:

I have a spreadsheet called "collector.xls" that contains a macro

"auto_open", which is
intended to execute when ever the sheet is opened. I am calling this

sheet from another
sheet (opening the sheet in question and then calling a macro in the

sheet I just
opened"), as in



Workbooks.Open Filename:="C:\IPT\timesheets\Collector.xls"
Application.Run "Collector.xls!Collectorcheckandmove"

My question is whether the auto-open macro in the collector will execute

before the
macro
I am calling from the external spreadsheet.

Thanks for he response

John Baker





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
Priority (with macro??) Alonso[_2_] Excel Worksheet Functions 4 October 25th 08 01:02 PM
Auto_Open Macro Trying to Excel Excel Discussion (Misc queries) 2 April 13th 07 07:08 AM
Button fails to call macro when open an Excel via Intranet tigertax Excel Discussion (Misc queries) 1 April 12th 05 10:21 AM
Auto_Open vs. macro John Wilson Excel Programming 0 September 22nd 03 05:44 PM
Workbook Open Vs Auto_Open Soniya Excel Programming 2 September 18th 03 11:43 AM


All times are GMT +1. The time now is 11:29 AM.

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

About Us

"It's about Microsoft Excel"