
Save Access report to specific Excel Worksheet
I have a P&L report in Access97 which includes 5 subreports: SALES,
COGS, R&D, S&M, G&A. I am trying to export the results from each
subreport to Excel, but have the SALES subreport saved to Sheet1 of my
Excel workbook, COGS saved to Sheet2, and so on.
I have can save my report as an Excel workbook, but not to a specific
sheet in that workbook.
The code that I have developed so far is as follows:
Public Sub ExcelSales()
Dim objXL As New Excel.Application
objXL.Visible = True
objXL.Workbooks.Open "H:\Application Development\Amgen\P & L
Template.xls"
objXL.Windows(1).Visible = True
objXL.Worksheets(1).Range("A1:G25").Clear
objXL.Worksheets(2).Range("A1:G25").Clear
objXL.Worksheets(3).Range("A1:G25").Clear
objXL.Worksheets(4).Range("A1:G25").Clear
objXL.Worksheets(5).Range("A1:G25").Clear
objXL.Worksheets(1).Activate
DoCmd.SelectObject acReport, "srptSales", True
??? DoCmd.RunCommand acCmdSaveAs ???
***THIS IS WHERE I AM AT A LOSS***
objXL.Workbooks(1).Close SaveChanges:=True
objXL.Quit
Set objXL = Nothing
End Sub
If it is not possible to "push" the report from Access to Excel, does
anyone have code to "pull" the report into Excel from Access?
--
TIA,
Randy Shore
Data Design
805.494.3439
Sent via Deja.com http://www.*-*-*.com/
Before you buy.