Private Sub Document_New()
'
'Note the location where you create your text file
'must be changed in two places in this code - the following line and...
oNum = System.PrivateProfileString("C:\increment.txt", "InvNmbr", "oNum")
If oNum = "" Then
oNum = 1
Else
oNum = oNum + 1
End If
'you must also change the text file path here (next line) as well
System.PrivateProfileString("C:\increment.txt", "InvNmbr", "oNum") = oNum
ActiveDocument.Bookmarks("oNum").Range.InsertBefore Format(oNum, "00#")
ActiveDocument.SaveAs FileName:="path" & Format(oNum, "00#")
End Sub
|