ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do not save macro with workbook (https://www.excelbanter.com/excel-programming/427787-do-not-save-macro-workbook.html)

Jeff

Do not save macro with workbook
 
I have a template with a startup macro in it and I would like to not save the
macro when they save the workbook. There are other macros in there that I
would like to save with the file. Any good ideas? Thanks! Jeff

Dave Peterson

Do not save macro with workbook
 
You could remove the macro, but that would depend on what the user's security
settings are.

Since you're keeping other macros, why not just make it so that it doesn't run?

Sub Workbook_Open()
if me.path < "" then
exit sub
end if

'real code here
End sub

Or

Sub Auto_Open()
if thisworkbook.path < "" then
exit sub
end if

'real code here
End sub


Jeff wrote:

I have a template with a startup macro in it and I would like to not save the
macro when they save the workbook. There are other macros in there that I
would like to save with the file. Any good ideas? Thanks! Jeff


--

Dave Peterson

Jeff

Do not save macro with workbook
 
That will work. Thanks you Dave!

"Dave Peterson" wrote:

You could remove the macro, but that would depend on what the user's security
settings are.

Since you're keeping other macros, why not just make it so that it doesn't run?

Sub Workbook_Open()
if me.path < "" then
exit sub
end if

'real code here
End sub

Or

Sub Auto_Open()
if thisworkbook.path < "" then
exit sub
end if

'real code here
End sub


Jeff wrote:

I have a template with a startup macro in it and I would like to not save the
macro when they save the workbook. There are other macros in there that I
would like to save with the file. Any good ideas? Thanks! Jeff


--

Dave Peterson



All times are GMT +1. The time now is 10:52 AM.

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