Hi All,

need a big help in this one as i am confused my self why it does not work, basically all i want to do is to generate a invoice number whenever i save and reopen and increment by one below is the command i used and it still does not work

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Workbook"
Const sKEY As String = "Open_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

'Saves Data In
'regedit, HKEY_Current_User, Software, VB & VBA Program Settings, Excel, Invoice, Invoive Key

'Auto Number'
With ThisWorkbook.Sheets("Sheet1")

With .Range("B1")

nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&

End With
End With
End Sub