Preventing macro from .xlt from executing in a .xls

X

XxLicherxX

Hello everyone,

I am new to this, so hopefully this isn't too stupid of a question.

I have a created a .xlt with some macros in it. A user double clicks on
this .xlt file, some macros run, the user makes the necessary changes
to the file and saves it as a .xls. When the user saves it, some more
macros run.

Now when the user opens or saves the .xls file, the same macros will
run again, however, I don't want them to run again. What can I do to
stop these macros from executing in the .xls files?

Thanks

Dave
 
R

Ron de Bruin

Hi

You can test the ThisWorkbook path
A template have no path

Sub test()
If Len(ThisWorkbook.Path) = 0 Then
MsgBox "run the code it is a template"
Else
MsgBox "The file is a xls"
End If
End Sub
 

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