ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open method used (https://www.excelbanter.com/excel-programming/309651-open-method-used.html)

Herminio

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


Chip Pearson

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/




Herminio[_2_]

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/


Tom Ogilvy

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/




Herminio[_3_]

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


Dave Peterson[_3_]

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


Tom Ogilvy

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/




Herminio[_4_]

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

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


Herminio[_5_]

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


Chip Pearson

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/




Herminio[_6_]

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



All times are GMT +1. The time now is 03:01 AM.

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