exporting excel
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Exporting to Excel

Exporting to Excel

resolvedResolved · Low Priority · Version 2003

replyReply Thu 10 Jul 2008, 15:55Delegate David said...

David has attended:
Access VBA course

Exporting to Excel

I would like to know how to code in Access the exporting of more than one table or query into a single excel spreadhseet as multiple worksheets i.e one tab for each query/table.

Thanks,
David

For upcoming training course dates see: Pricing & availability

replyReply Fri 11 Jul 2008, 11:48Trainer Roy said...

RE: Exporting to Excel

One way to get data across is the Excel.Range.CopyFromRecordset method:

'Set up a Recordset based on either an SQL string or directly on a table (option adCmdTableDirect to the Open method)

Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet

Set xlbook = GetObject(bookPath)
Set xlsheet = xlbook.Worksheets("WS Name")
xlsheet.Range("Data").CopyFromRecordset recset

Then just do this as many times as necessary, for different Recordsets and Ranges.

GetObject is a function in the VBA.Interaction module, which retrieves an (ActiveX) object from a specified file. In this case, the object is an Excel Workbook. The Excel application is started automatically

 

Please browse our web site to find out more about
ms+access+course/ and other Microsoft training courses.

Access tip:

Design View in Relationship window

Your in the Relationship window and changes are required to be made to a Table's design.

Rather than exiting the Relationship window, if you perform a right-mouse click on the table, it opens that table up in Design view

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard