Hi Ken,
You could use the registry for keeping track of a sequential number. The values will be entered in: HKEY_CURRENT_USER\Software\VB and VBA Program Settings
Code would look like this:
Private Sub GetDocNumber()
Dim sDocNumber As String
Dim iDocNumber As Integer
Dim sYear As String
Dim sYearNow As String
'read values from the registry
sDocNumber = GetSetting("ACT", "Invoices", "SeqNumber", ""

sYear = GetSetting("ACT", "Invoices", "Year", ""

sYearNow = Format(Now, "yyyy"
'if idocnumer = "" then this is the first document
'if sYear <> sYearNow, we entered a new year so we start again at 1 (f.e.)
If sDocNumber = "" Or sYear <> sYearNow Then
iDocNumber = 1
'else add one to the doc number
Else
iDocNumber = sDocNumber + 1
End If
'find the next number to use and add leading zero's
If iDocNumber < 10 Then
sDocNumber = "00" & iDocNumber
ElseIf iDocNumber > 9 And iDocNumber < 100 Then
sDocNumber = "0" & iDocNumber
End If
sDocNumber = sYearNow & "_" & sDocNumber
'so now you've got a new sequential number which you can put in
'f.e. a bookmark, documentproperties, documentname.....
'now enter the new values in the registry
SaveSetting "ACT", "Invoices", "SeqNumber", iDocNumber
SaveSetting "ACT", "Invoices", "Year", sYearNow
End Sub
If you don't want to or are not allowed to enter any values in the registry you can do a simular thing using an ini-file.
Hope this helps.
Regards,
Unica