Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to Excel VBA help

Status
Not open for further replies.

newbee2

Technical User
Apr 21, 2002
85
Hi,
I have managed to get three queries to export to an excel spreadsheet using the following code I set up in a module. I am working blind which is nothing new.

Function ExportToExcel()

'Run queries to create tables to use for export to an excel spread sheet
'The queries have parametric equations to select the required data for the time period.
'three queries have to be exported.
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "MarketInvoiceToDateBudgetSumQuery1", "C:\My documents\Copy of BUDGET04", hasfieldnames = True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "MarketSalesEnquiryInstantInvoiceSumQuery", "C:\My documents\Copy of BUDGET04", hasfieldnames = True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "MarketUnionConvertSumQuery", "C:\My documents\Copy of BUDGET04", hasfieldnames = True
DoCmd.close acform, "Choose Report"
End Function

1)Is it possible to get all three to go to one worksheet in the workbook if it is designated.
2) How do you designate a particular worksheet?. I have tried [Copy of BUDGET04]!SheetA , but it doesn't work.
3)And if so how do you get them to append to each other, one after the other without over writing?.
When they export thet create there own worksheets in the spreadsheet.

Thanking in advance anyone who can assist.
Kind Regards
Bill
 
You will want to use Automation.

Access97 - go to (watch wordwrap) and download Auto97.exe.

Access2K - go to (watch wordwrap) and download Auto2000.exe.

AccessXP - go to (watch wordwrap) and download Xpautomation.exe

Once the appropriate file is downloaded, install it. All three files provide excellent examples on how to add worksheets to workbooks through automation and how to transfer data from Access to Excel (look at the CopyFromRecordset method).


John Ruff - The Eternal Optimist :)
 
ThanKyou,
I was getting desperate at the daunting task.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top