How can I disable macros after the initial open?

G

Guest

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?
 
G

Guest

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
 
G

Guest

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.
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top