Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open method used

Hi fellows!
I need know what method was used to open my workbook, that is, a mous
click or a VBA workbooks.open.
Is there any way to find out it?
Thanks!
Hermínio

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Open method used

Herminio,

One way would be to use the Auto_Open event procedure to set a
flag variable. Because Auto_Open is not called executed when a
workbook is opened via VBA, it will run only when the workbook is
opened manually. E.g.,

Dim OpenByUI As Boolean

Sub Auto_Open()
OpenByUI = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Herminio " wrote in
message ...
Hi fellows!
I need know what method was used to open my workbook, that is,
a mouse
click or a VBA workbooks.open.
Is there any way to find out it?
Thanks!
Hermínio.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open method used

Dear Chip.
Unfortunately I am using Excel 2000 and it looks like it does not
support the Auto_Open event.
The nearest one to that would be the Activate event, but this is
executed after the Open, in both manual and VBA calls.
Thank you anyway.
Regards,
Herminio.


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Open method used

In a standard module, create a sub with the name Auto_Open (don't do it in a
sheet module, thisworkbook module or a userform module).

Dim OpenByUI As Boolean

Sub Auto_Open()
OpenByUI = True
End Sub

It is supported in xl5 to xl2003.

--
Regards,
Tom Ogilvy


"Herminio " wrote in message
...
Dear Chip.
Unfortunately I am using Excel 2000 and it looks like it does not
support the Auto_Open event.
The nearest one to that would be the Activate event, but this is
executed after the Open, in both manual and VBA calls.
Thank you anyway.
Regards,
Herminio.


---
Message posted from http://www.ExcelForum.com/



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

Dears Tom and Chip.
I've created a standard module with an Auto_Open subroutine, as yo
said, and, it’s true, that code is *only* executed when you open th
workbook manually (mouse click or Enter key).
Nevertheless the Auto_Open code is executed *after* the Workbook_Ope
subroutine. That's too late, because the code I want to bypass, in cas
of a "remote" VBA Workbooks.Open, resides inside the Workbook_Ope
subroutine. So, the problem remains unsolved.
Thank you any way.
Regards,
Herminio

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Open method used

If you want to avoid all of the workbook_open event, you could do this when you
open the workbook mechanically:

application.enableevents = false
workbooks.open filename:= ....
application.enableevents = true



"Herminio <" wrote:

Dears Tom and Chip.
I've created a standard module with an Auto_Open subroutine, as you
said, and, it’s true, that code is *only* executed when you open the
workbook manually (mouse click or Enter key).
Nevertheless the Auto_Open code is executed *after* the Workbook_Open
subroutine. That's too late, because the code I want to bypass, in case
of a "remote" VBA Workbooks.Open, resides inside the Workbook_Open
subroutine. So, the problem remains unsolved.
Thank you any way.
Regards,
Herminio.

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Open method used

Use only the Auto_open macro - move the code from the workbook_open event to
the Auto_Open event. Then when it is opened remotely, the code doesn't run.
(If I understand the situation correctly).

--
Regards,
Tom Ogilvy

"Herminio " wrote in message
...
Dears Tom and Chip.
I've created a standard module with an Auto_Open subroutine, as you
said, and, it's true, that code is *only* executed when you open the
workbook manually (mouse click or Enter key).
Nevertheless the Auto_Open code is executed *after* the Workbook_Open
subroutine. That's too late, because the code I want to bypass, in case
of a "remote" VBA Workbooks.Open, resides inside the Workbook_Open
subroutine. So, the problem remains unsolved.
Thank you any way.
Regards,
Herminio.


---
Message posted from http://www.ExcelForum.com/



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open method used

That's it, Tom!
Congratulations!
Thank you and have a nice day!
Herminio

--
Message posted from http://www.ExcelForum.com

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open method used

Thank you, Dave.
I need bypass only part of the Workbook_Open code,
but it was nice to learn the new facility you've pointed out.
Regards,
Hermínio

--
Message posted from http://www.ExcelForum.com

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Open method used

Herminio,

Take all the code out of the Workbook_Open event procedure and
put it in the Auto_Open macro.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Herminio " wrote in
message ...
Dears Tom and Chip.
I've created a standard module with an Auto_Open subroutine, as
you
said, and, it's true, that code is *only* executed when you
open the
workbook manually (mouse click or Enter key).
Nevertheless the Auto_Open code is executed *after* the
Workbook_Open
subroutine. That's too late, because the code I want to bypass,
in case
of a "remote" VBA Workbooks.Open, resides inside the
Workbook_Open
subroutine. So, the problem remains unsolved.
Thank you any way.
Regards,
Herminio.


---
Message posted from http://www.ExcelForum.com/





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open method used

I'll try.
I have to check if my Workbook_BeforeClose subroutine will not presen
any new error in that case.
Thank you.
Regards,
Herminio

--
Message posted from http://www.ExcelForum.com

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
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Workbook Open method Gwen[_2_] Excel Programming 2 June 2nd 04 05:53 PM
EXCEL.exe stays open after Quit method in an HTA myriams9 Excel Programming 5 December 4th 03 07:06 AM
Open Method of workbooks class failed kiran[_2_] Excel Programming 0 November 6th 03 09:58 PM
Open Method disabling Macros Bryan Steffen Excel Programming 0 July 16th 03 01:34 PM


All times are GMT +1. The time now is 03:46 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"