Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Troy
 
Posts: n/a
Default How can I disable macros after the initial open?

I have created an excel template with macros in Excel 2003. The template
works great. I am trying to figure out how to automatically disable the
macros after the initial open and save of the template. I tried to open the
xls file after I did a test run and the macros were still active. How can I
fix this?
  #2   Report Post  
Posted to microsoft.public.excel.misc
bigwheel
 
Posts: n/a
Default How can I disable macros after the initial open?

I'm sure that there will be a more elegant solution to this but, how about
setting a global variable when the macro runs first which you use as a flag
to by-pass subsequent running of any macros i.e. flag = false then

If flag then
do something
else

endif

"Troy" wrote:

I have created an excel template with macros in Excel 2003. The template
works great. I am trying to figure out how to automatically disable the
macros after the initial open and save of the template. I tried to open the
xls file after I did a test run and the macros were still active. How can I
fix this?

  #3   Report Post  
Posted to microsoft.public.excel.misc
Troy
 
Posts: n/a
Default How can I disable macros after the initial open?

Not sure what or where I would do this. Unless you are talking about the VB
code. I have done some of that but not a lot. Would have to figure out how to
do that.

"bigwheel" wrote:

I'm sure that there will be a more elegant solution to this but, how about
setting a global variable when the macro runs first which you use as a flag
to by-pass subsequent running of any macros i.e. flag = false then

If flag then
do something
else

endif

"Troy" wrote:

I have created an excel template with macros in Excel 2003. The template
works great. I am trying to figure out how to automatically disable the
macros after the initial open and save of the template. I tried to open the
xls file after I did a test run and the macros were still active. How can I
fix this?

  #4   Report Post  
Posted to microsoft.public.excel.misc
bigwheel
 
Posts: n/a
Default How can I disable macros after the initial open?

You say that you have created a macro, what does it do? Could you post an
example?

"Troy" wrote:

Not sure what or where I would do this. Unless you are talking about the VB
code. I have done some of that but not a lot. Would have to figure out how to
do that.

"bigwheel" wrote:

I'm sure that there will be a more elegant solution to this but, how about
setting a global variable when the macro runs first which you use as a flag
to by-pass subsequent running of any macros i.e. flag = false then

If flag then
do something
else

endif

"Troy" wrote:

I have created an excel template with macros in Excel 2003. The template
works great. I am trying to figure out how to automatically disable the
macros after the initial open and save of the template. I tried to open the
xls file after I did a test run and the macros were still active. How can I
fix this?

  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default How can I disable macros after the initial open?

If you're really working with a template and a normal workbook, you could add a
line like:

if thisworkbook.path < "" then
exit sub
end if

If the workbook hasn't been saved, then there is not path--it must be a
template.

If you're not using a .xlt file -- just using a .xls and calling it a template,
then this won't work.

But you could use some other technique:

if lcase(thisworkbook.fullname) = lcase("whateverpath\filename.xls") then
'you're still looking at the "template"
end if



Troy wrote:

I have created an excel template with macros in Excel 2003. The template
works great. I am trying to figure out how to automatically disable the
macros after the initial open and save of the template. I tried to open the
xls file after I did a test run and the macros were still active. How can I
fix this?


--

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
CSV formatted files open odly in Excel 2000 Janski Excel Discussion (Misc queries) 3 November 24th 05 07:58 PM
Open saved projects automatically? Stuhump3 Excel Discussion (Misc queries) 1 September 9th 05 07:19 PM
open workbook automatically Jo Coen Excel Discussion (Misc queries) 2 July 29th 05 11:57 AM
Can Only open files using file ~ open tek4u Excel Discussion (Misc queries) 4 July 11th 05 05:31 PM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM


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