Excel Invoice Template - Invoice Number Generator

Excel Invoice Number Generator

        When the invoice template is opened, it automatically creates a .txt file named" invoicenr.txt" in the folder it is in. In the created .txt file, 2000 number is entered as an example. Then, when Excel workbook is closed and opened, it can be seen that this number is 2001 on the invoice number cell (G3 cell).

       If  user wants , can enter a different number in the .txt file . When the workbook is closed and opened, the entered number will appear it increased one by one .
VBA function codes that enable the creation of the .txt file:
Public Function GetInvoiceNr() As Long
Dim WholeLine As String, fName As String
Dim InvNr As Long
Dim CommandButton2 As CommandButton
Dim sor

Application.DisplayAlerts = False
On Error GoTo NewFile
fName = ActiveWorkbook.Path & "\invoicenr.txt"

Open fName For Input Access Read As #1
    Line Input #1, WholeLine
    InvNr = WholeLine
    InvNr = InvNr + 1
Close #1
Open fName For Output As #1
    Print #1, InvNr
Close #1
Application.DisplayAlerts = True

GetInvoiceNr = InvNr
GoTo Netd
InvNr = 2000

GoTo SaveNewFile
On Error GoTo 0
GoTo Netd
On Error GoTo 0
End Function

1 comment:

  1. This text is worth everyone’s attention. How can I find out more? Really great news!!! this information is well worth looking everyone. Good tips.
    Invoice generator