Access -> Excel Template with macros
Posted on 2010-09-08
I am using the following code to export from Access to Excel:
Dim xlObj As Object, xltPath As String
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("DMEL-Excel-Query")
xltPath = GetProjectDirectory() & "MEL\DMELHeader.xltx"
Set xlObj = CreateObject("Excel.Application")
.Range("E3") = DLookup("[ProjectName]", "Main-ProjectInformation")
.Range("E4") = DLookup("[ProjectLocation]", "Main-ProjectInformation")
Set xlObj = Nothing
I am trying to create Excel Macros that do certain things, and I would like to create them in the template file so when I export to Excel I use the template file, copy in the data, and then have access to the macros.
Is this possible? If so do I need to save as something else? or do something different with my template file?
Any advice is greatly appreciated.