Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 January 21st, 2006, 05:21 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default exporting 2 excel by macro


  Hi friends:),

 I am trying to generate and data from access using query through front end by an combo box (i.e) ,for exmp i am have 5 datas which have an master field name of employee name based on the employee name i am taking the other datas by using combo box and command button . I got the good reslut by our community guy's .Now i want to export data to excel automatically using macor . pls help me in this issue. is it possible for me to export the data to the excel file without giving an file.xls name (i.e.) default or the excel sheet that i prefer which already contain macros .

 Or export the data with out macro by VB coding is also preferrable.Bye

P.A.P.Raguv
 
Old January 27th, 2006, 03:07 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Well, of course you cannot export to a file without knowing its name. But if you mean that you don't want to be prompted on-screen for a file name, of course you can put the filename into your code.

Create a new macro
Set the action to "OutputTo"
Set Object Type to the table or query you want to output
Set OutputFormat to Microsoft Excel (*.xls)
Set the aoutput file to the path & filename, eg: “C:\Temp\TableOfStuf.xls” (don’t include the quote marks. Leave this blank to be prompted for the file name.)
Set Autostart to No.

When you run the macro, it will create your file...
If the file already exists, you will be asked if you want to overwrite it.

In VB this would be:
Code:
 DoCmd.OutputTo acTable, "Tbl_Qry", "MicrosoftExcel(*.xls)", "C:\Sheet.xls", False
 
Old January 30th, 2006, 02:38 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default

Hi brain,
          I got ur idea and its work ,sorryi did'nt mention that i am using an front end for generating this one (i.e.)previously i am using an combo box and an command button to genetare by report to view it as report preview through an front end (From View) but i want to convert this method to export the data directlly to the excel by the same combo box & command button ... if ur not able to understand my say pls reply me....

P.A.P.Raguv





Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro in Excel mateenmohd Excel VBA 3 June 16th, 2008 07:34 PM
Exporting to excel michaeltanfeliz Beginning VB 6 2 May 3rd, 2008 05:26 AM
Excel 2000 vs Excel 2002 Macro Issue williadn Excel VBA 1 July 14th, 2005 09:09 AM
Exporting to Excel swhite Access VBA 2 September 18th, 2003 09:42 AM





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