Here is an alternate approach that has worked for me.
Create this subroutine and run it once in a new docoment:
Sub CreateCounter()
Dim aVar As Variable
Dim N As Integer
For Each aVar In ActiveDocument.Variables
If aVar.Name = "myCounter" Then N = aVar.Index
Next aVar
If N = 0 Then
ActiveDocument.Variables.Add Name:="myCounter", Value:=Format$(0, "0000")
Else
ActiveDocument.Variables(N) = Format$(0, "0000")
End If
End Sub
After running the subroutine, go back to the main document and insert a
field of type "DocVariable" where the count is supposed to appear and name
it "myCounter". Alt plus F11 and under "ThisDocument" create the following
subroutine:
Private Sub Document_New()
Dim I As Integer
I = CInt(ThisDocument.Variables("myCounter").Value)
I = I + 1
ThisDocument.Variables("myCounter").Value = I
ThisDocument.Save
ActiveDocument.Variables("myCounter").Value = Format$(I, "0000")
ActiveDocument.Fields.Update
End Sub
Go back to the main document and after finsising up anything beside the
count that should be part of a template, save the file as a document
template, "dot". Each time a new document is created from this template,
the document variable is incremented by one and the change is saved to the
template.
Steve