jmstarbuck
Programmer
I'm "exporting" a query to Excel with the following:
Code:
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = Excel.Application
Set xlBook = xlApp.Workbooks.Add
xlApp.DisplayAlerts = False
For i = xlBook.Worksheets.Count To 2 Step -1
xlBook.Worksheets(1).Delete
Next i
xlApp.DisplayAlerts = True
Set xlSheet = xlBook.ActiveSheet
xlSheet.Name = "ProgramReport"
With xlSheet
'copy data from recordset to excel
.Range("A1").CopyFromRecordset rst
...
That works fine. Now I would like to also export a macro to that workbook that my users can run later. My thought is to have a large block of text somewhere in Access that is actually an Excel macro and then do something nifty like ".addmacro LgBlkText"
I'm not quite sure how to say this correctly, which is probably why I am having trouble finding an answer with a search.
Any ideas?
Janice