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.
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
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
oSheet.PrintOut() 'print command
oExcel = Nothing
Kill("D:\Receipt.Xlsx") 'deletes the file
Have a nice print
Last edited by aeskan; 05-27-2012 at 7:02 PM.
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 by aeskan; 05-27-2012 at 8:22 PM.