Hi,
I have a lot of data that needs to be displayed, then edited and finally printed. Because it needs to be edited but not saved in the database, i can't use either form or report. I thought the best solution was to create an excel template with static cells for logo, field names, etc... and then using VBA to send a query to a new .xls file based on the template.
I'm a rookie when it comes to anything with Excel, so forgive me my unknowingness
I'm using the following code to create a new .xls file.
Dim AppXls As Excel.Application
Dim ObjWb As Excel.Workbook
Dim ObjWs As Excel.Worksheet
Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add
Set ObjWs = ObjWb.Worksheets.Add
ObjWs.Range("A1").Value = "1"
ObjWb.SaveAs (CurrentProject.path & "\saved PBR\TestCreate.xls")
ObjWb.Close (SaveChanges = False)
This ofcourse is just a test to see if creating a file and writing to it would work. I think I need to set a property to objWb or objWs in order to bind a template to the document.
Any help using excel and VBA this way is appreciated, links to good sites are all welcome ofcourse.
Thanks in advance
Joeri
I have a lot of data that needs to be displayed, then edited and finally printed. Because it needs to be edited but not saved in the database, i can't use either form or report. I thought the best solution was to create an excel template with static cells for logo, field names, etc... and then using VBA to send a query to a new .xls file based on the template.
I'm a rookie when it comes to anything with Excel, so forgive me my unknowingness
I'm using the following code to create a new .xls file.
Dim AppXls As Excel.Application
Dim ObjWb As Excel.Workbook
Dim ObjWs As Excel.Worksheet
Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add
Set ObjWs = ObjWb.Worksheets.Add
ObjWs.Range("A1").Value = "1"
ObjWb.SaveAs (CurrentProject.path & "\saved PBR\TestCreate.xls")
ObjWb.Close (SaveChanges = False)
This ofcourse is just a test to see if creating a file and writing to it would work. I think I need to set a property to objWb or objWs in order to bind a template to the document.
Any help using excel and VBA this way is appreciated, links to good sites are all welcome ofcourse.
Thanks in advance
Joeri