Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2007, 09:16 AM
Authorized User
 
Join Date: Feb 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export to Excel Question

How would I export the results from an Access query to an Excel spreadsheet and at the same time open the spreadsheet to view the results by using a cmd button?

I've used this line of code to export information from a table to excel:

DoCmd.TransferSpreadsheet acExport, _
SpreadsheetTypeExcel9, "tblMain", _
"c:\bulk\Main.xls"

However, I have to manually find the excel file and open it to view the data.

 
Old May 11th, 2007, 12:52 PM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you know where the file will be put and what the name is, you just have to add some code after the one you already have to open the excell file...

So on the same action button you put the 2 codes one after the other...

You know how to do this?

 
Old May 11th, 2007, 01:24 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this:
DoCmd.OutputTo acOutputQuery, "query name goes here", acFormatXLS, "path name goes here", -1

 
Old May 11th, 2007, 03:09 PM
Authorized User
 
Join Date: Feb 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

stealthdevil,

that line of code did it! thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to Excel ramuis78 ASP.NET 2.0 Basics 2 May 30th, 2007 05:51 AM
export to excel roy_mm Reporting Services 0 September 2nd, 2006 11:53 PM
excel export msrnivas .NET Web Services 1 June 10th, 2004 08:29 AM
excel export msrnivas Classic ASP Components 0 June 9th, 2004 10:15 PM
excel export msrnivas .NET Web Services 1 March 29th, 2004 03:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.