receipt printing

jsj1411

New member
Joined
May 25, 2012
Messages
3
Programming Experience
Beginner
hey guys , i need some help and guidance regarding my college project. i'm working on a sales system . i have a form which consist of all the following information( item code , item name , item price , quantity of item ) which is display using a data grid . data input by user using text box and all this information will be stored in a database(sales database) i'm using ms access 2007. the grand total will be displayed in a text box . and amount paid will be input in a text box too , my major problem now is how to i create a reciept that will have all this information of the purcase. i have a reciept button . what the next step ? i dont have any idea how to get the reciept done.

thanks guys
 
One of the solutions is:


1. Add > Microsoft Excel 14.0 Object Library to
your project's references
2. Make your receipt form as you wish in
Excel and save it for example as "Template1.Xlsx" for the further use
3. Write the following codes to print your database

PrivateSub Do_Print()

Dim oExcel AsObject = GetObject("", "Excel.Application")
Dim oBook AsObject = oExcel.Workbooks.Open("D:\Template1.Xlsx")
Dim oSheet AsObject = oBook.Worksheets(1)

oSheet.PageSetup.CenterHeaderPicture.FileName = logoFile
'if is necessary
oSheet.PageSetup.CenterHeader = "&G"'if is necessary
oSheet.PageSetup.HeaderMargin = 30 'if is necessary
'fill Excel sheet cells here with your data
oSheet.Range("B3").Value = itemCode

oSheet.Range(
"B6").Value = itemName
oSheet.Range(
"D10").Value = itemPrice

'and other items
'finally save, close and print Excel file
oSheet.PageSetup.PrintArea = "$A$1:$K$67" 'makes your print area

oBook.SaveAs("D:\Receipt.Xlsx")
oSheet.PrintOut() 'print command
oBook.close()
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel =
Nothing
Kill("D:\Receipt.Xlsx") 'deletes the file

EndSub

Have a nice print
 
Last edited:
Note: If it was useful for you, for more information and help about VB functions for Excel, active your Excel Developer menu tab and then open Visual Basic Editor there in Excel, And fallow it's Help.
 
Last edited:
Back
Top