ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Remove/suppress Auto_Open macro (https://www.excelbanter.com/excel-programming/350786-remove-suppress-auto_open-macro.html)

Steve C

Remove/suppress Auto_Open macro
 
I created a template with an opening form launched by an Auto_Open macro.
Once a new spreadsheet is created and saved, I would like the form to be
supressed when the workbook is subsequently re-opened. Is there a way to do
this with an Auto_Close macro? Thanks.

Steve C

GB

Remove/suppress Auto_Open macro
 
I have handled this a number of different ways. One, is that you could store
a value on a very hidden worksheet, and do a comparison of if that value is
present when opening. Could use the registry, although if you go to a
different computer and your registry didn't follow you, then oops. You could
do some other "investigation" that would look for an indicator. Also, you
could actually revise the base code prior in the before save of the document.
I can't remember which reference allows you to access/modify the VBA code
from within the VBA code, but I do know you want to be careful in
implementation. :) Delete one too many things, and you may have lost a years
worth of work. :) That one didn't happen to me, but sure was concerned.


"Steve C" wrote:

I created a template with an opening form launched by an Auto_Open macro.
Once a new spreadsheet is created and saved, I would like the form to be
supressed when the workbook is subsequently re-opened. Is there a way to do
this with an Auto_Close macro? Thanks.

Steve C


Dave Peterson

Remove/suppress Auto_Open macro
 
If it's a real template that's creating a new workbook, you could use:

Option Explicit
sub auto_open()
if thisworkbook.path = "" then
'never been saved
'show userform
else
'it's not a template anymore
'do nothing
end if
end sub

Steve C wrote:

I created a template with an opening form launched by an Auto_Open macro.
Once a new spreadsheet is created and saved, I would like the form to be
supressed when the workbook is subsequently re-opened. Is there a way to do
this with an Auto_Close macro? Thanks.

Steve C


--

Dave Peterson

Steve C

Remove/suppress Auto_Open macro
 
That looks like a solution. I'll give it a try. Thanks!

"Dave Peterson" wrote:

If it's a real template that's creating a new workbook, you could use:

Option Explicit
sub auto_open()
if thisworkbook.path = "" then
'never been saved
'show userform
else
'it's not a template anymore
'do nothing
end if
end sub

Steve C wrote:

I created a template with an opening form launched by an Auto_Open macro.
Once a new spreadsheet is created and saved, I would like the form to be
supressed when the workbook is subsequently re-opened. Is there a way to do
this with an Auto_Close macro? Thanks.

Steve C


--

Dave Peterson



All times are GMT +1. The time now is 09:20 AM.

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