Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Macro to open file bypasses Auto_Open

I have the following code.

Workbooks.Open Filename:=vOpen, UpdateLinks:=3

But when I run this it does not process the macro Auto_Open.

Why is this?

I would like for code to run on the opening of the file regardless of how
the user opened it. (ie. If they opened it using File / Open on the menu
then yes, the Auto_Open would run. But I also want code to run even if
they write their own macro to open it.)

Thank you,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to open file bypasses Auto_Open

That's the way excel was designed to work.

Lots of times, developers want to open the workbook without having that macro
run (maybe they're automating something and want to avoid some msgbox/inputbox
in that auto_open procedure.

But MS did give you a way to run that procedure.

dim wkbk as workbook
set wkbk = workbooks.open(filename:=vopen, updatelinks:=3)
wkbk.RunAutoMacros which:=xlAutoOpen

(there are other options for the Which parm, too--see VBA's help for
RunAutoMacros).

Interestly (well, maybe <bg), MS does the opposite with the Workbook_Open
event. That runs unless you stop it.

dim wkbk as workbook
application.enableevents = false
set wkbk = workbooks.open(filename:=vopen, updatelinks:=3)
application.enableevents = true



Steven wrote:

I have the following code.

Workbooks.Open Filename:=vOpen, UpdateLinks:=3

But when I run this it does not process the macro Auto_Open.

Why is this?

I would like for code to run on the opening of the file regardless of how
the user opened it. (ie. If they opened it using File / Open on the menu
then yes, the Auto_Open would run. But I also want code to run even if
they write their own macro to open it.)

Thank you,

Steven


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Macro to open file bypasses Auto_Open


Never mind. I think this was an EnableEvents issue.

Regards,

Steven

"Steven" wrote:

I have the following code.

Workbooks.Open Filename:=vOpen, UpdateLinks:=3

But when I run this it does not process the macro Auto_Open.

Why is this?

I would like for code to run on the opening of the file regardless of how
the user opened it. (ie. If they opened it using File / Open on the menu
then yes, the Auto_Open would run. But I also want code to run even if
they write their own macro to open it.)

Thank you,

Steven

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to open file bypasses Auto_Open

Not if you were really using Auto_Open.

Steven wrote:

Never mind. I think this was an EnableEvents issue.

Regards,

Steven

"Steven" wrote:

I have the following code.

Workbooks.Open Filename:=vOpen, UpdateLinks:=3

But when I run this it does not process the macro Auto_Open.

Why is this?

I would like for code to run on the opening of the file regardless of how
the user opened it. (ie. If they opened it using File / Open on the menu
then yes, the Auto_Open would run. But I also want code to run even if
they write their own macro to open it.)

Thank you,

Steven


--

Dave Peterson
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
with a macro open a workbook without the Auto_Open running OlieH Excel Programming 3 May 21st 08 06:29 PM
Workbook Open bypasses Query Refresh ssGuru Excel Programming 3 February 12th 08 07:47 PM
Macro runs upon wkbk open, but no Workbook_Open or Auto_Open Macro Ron Coderre Excel Programming 2 September 26th 06 05:50 PM
Auto_Open only on initial file open Joe Granda Excel Programming 2 January 15th 04 10:20 PM
Auto_Open vs Open and call macro --priority question John Baker Excel Programming 3 December 7th 03 04:26 PM


All times are GMT +1. The time now is 11:53 PM.

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"