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
 
Top