Running code on new file from template

F

FTL

Hi
Anyone who can tell me how to run some code when I make a new workbook from
a template?
I want it to run only when I create a new document, not when opening it
later.

FTL
 
D

Dick Kusleika

FTL

There is no event for creating a new workbook from a template, but you can
use the Workbook_Open event. One way to prevent the code from running after
the first time is to check the Path property. If it's been saved, it will
have a path.

Sub Workbook_Open()

If Len(Me.Path) = 0 Then
'Do stuff
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