Excel VBA Bangla Tutorial 49 : Invoice | Billing system & automatically export in PDF format
HASAN ACADEMY HASAN ACADEMY
24.4K subscribers
67,216 views
1K

 Published On Feb 1, 2019

To create an Invoice/Billing system and automatically export it in PDF format using Excel VBA, you can follow these steps:

Open a new Excel workbook and create a template for the invoice/billing system. This can include details such as company name and address, customer name and address, invoice number and date, item description and quantity, unit price, total price, and payment details.

Add VBA code to the workbook to automate the invoice/billing system. Here's an example code for generating an invoice:

vbnet
Copy code
Sub GenerateInvoice()
'Get the invoice number and date
Dim invoiceNumber As String
invoiceNumber = InputBox("Enter the invoice number:")
Dim invoiceDate As Date
invoiceDate = InputBox("Enter the invoice date:")

'Get the customer details
Dim customerName As String
customerName = InputBox("Enter the customer name:")
Dim customerAddress As String
customerAddress = InputBox("Enter the customer address:")

'Get the item details
Dim itemDescription As String
itemDescription = InputBox("Enter the item description:")
Dim itemQuantity As Double
itemQuantity = InputBox("Enter the item quantity:")
Dim itemPrice As Double
itemPrice = InputBox("Enter the item price:")

'Calculate the total price
Dim totalPrice As Double
totalPrice = itemQuantity * itemPrice

'Insert the data into the worksheet
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Invoice")
ws.Range("B2").Value = invoiceNumber
ws.Range("B3").Value = invoiceDate
ws.Range("B5").Value = customerName
ws.Range("B6").Value = customerAddress
ws.Range("A9").Value = itemDescription
ws.Range("B9").Value = itemQuantity
ws.Range("C9").Value = itemPrice
ws.Range("D9").Value = totalPrice

'Export the invoice as PDF
Dim fileName As String
fileName = "Invoice " & invoiceNumber & ".pdf"
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fileName, Quality:=xlQualityStandard
End Sub
Customize the code to add more features, such as error handling, formatting, and multiple items.

Save the workbook and test the invoice/billing system by running the VBA code.

To use the Invoice/Billing system, you can open the workbook and run the VBA code to generate an invoice. The invoice will be automatically exported as a PDF file with the invoice number as the filename. You can then print or email the PDF file to the customer.

show more

Share/Embed