I have been trying to add a sequential numbering macro to a word document so that each time it is opened the document is given a new number. The form in question is to record 'near misses' and it would be helpful to be able to open and print off the form each time it was required to be filled in with the next number.
I have tried the code below:
Code:
Sub AutoNew()
FormNumber = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "Order")
If FormNumber = "" Then
FormNumber = 1
Else
FormNumber = FormNumber + 1
End If
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
"FormNumber") = FormNumber
ActiveDocument.Bookmarks("FormNumber").Range.InsertBefore Format(FormNumber, "00#")
ActiveDocument.SaveAs FileName:="path" & Format(FormNumber, "00#")
End Sub
But I get an error message at the line beginning 'System. Private' telling me that the _ is not a valid character.
Any help gratefully received