This is the technique I use. It presumes you are opening the template via shortcuts so that it never really opens the template, but a new workbook, each time. The workbook_open does the same thing yours does, with the exception you forgot to include the Sheet Name reference in yours. Best include that...
Also, I've designated cell AA1 as the "doublecheck" cell on my new workbook, and it will only increment the number if that cell is empty. The workbook_beforesave event not only increments the actual template, but it puts a flag in AA1 to make sure this workbook never does any of this activity again.
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Sheets("Sheet1")
If .Range("AA1") = "" Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Workbooks.Open Filename:= _
"C:\Documents and Settings\Jerry\My Documents\Excel Tips\Invoice.xlt", Editable:=True
.Range("B2").Value = .Range("B2").Value + 1
ActiveWorkbook.Close True
.Range("AA1") = "Incremented"
Application.ScreenUpdating = True
Application.EnableEvents = True
End If
End With
End Sub
Private Sub WorkBook_Open()
With Sheets("Sheet1")
If .Range("AA1") = "" Then .Range("B2").Value = .Range("B2").Value + 1
End With
End Sub
Bookmarks