I'm trying to make a document that has an "invoice" number that increases on the document that goes up every time I print the document. I found a macro code online but I keep getting the
Compile error
I'll attach a snap shot of what I'm getting with the piece that keeps screwing up highlighted.
Sub SerialNumber()
'
' SerialNumber Macro
'
'
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range
' Set prompt.
Message = "Enter the number of copies that you want to print"
' Set title.
Title = "Print"
' Set default.
Default = "1"
' Display message, title, and default value.
Numcopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\Users\JShewchuk\Documents\Macro\Settings.Txt", _
"MacroSettings", "SerialNumber")
If SerialNumber = "" Then
SerialNumber = 0
End If
Set Rngl = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0
While Counter < NumCopies
Rng1.Delete
Rng1.Text = Format(SerialNumber, "00#")
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
Counter = Counter + 1
Wend
'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Users\JShewchuk\Documents\Macro\Settings.Txt", "MacroSettings", _
"SerialNumber") = SerialNumber
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With

Is there something I'm doing wrong?