A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro or VB code to Export data to an Excel file?



 
 
Thread Tools Display Modes
  #11  
Old December 30th, 2009, 01:22 AM posted to microsoft.public.access.gettingstarted
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default Macro or VB code to Export data to an Excel file?

You can use the Transfer Spreadsheet function on your query. The button code
would be something like:

Private Sub MyButton_Click()
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, "QueryName", _
"C:\Test.xls",, "MyName"
End Sub

Just for your information, acSpreadsheetTypeExcel9 is Excel 97 which should
be readable by later versions, but you can also export to a later format.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"BobC" wrote in message
...
I have a query that assembles the data that I would like to routinely
export as an Excel file to a specific file location.

I would like it such that various users can 'just press a button' so to
speak and get the most current data from the database for use in an Excel
Pivot Table.

I would like either or both a Macro or VB code to do this. When I looked
at the Macro options this was not obvious?

Bob





  #12  
Old December 30th, 2009, 02:54 AM posted to microsoft.public.access.gettingstarted
BobC[_6_]
external usenet poster
 
Posts: 89
Default Macro or VB code to Export data to an Excel file?

Thanks! You guys/gals are doing us folks a lot of good!

Arvin Meyer [MVP] wrote:
Steve Santus basically haunts these newsgroups looking for business. He was
caught by the poster who answered him. Good professional quality help is
here for free.

  #13  
Old December 30th, 2009, 03:01 AM posted to microsoft.public.access.gettingstarted
BobC[_6_]
external usenet poster
 
Posts: 89
Default Macro or VB code to Export data to an Excel file?

Thanks John!

You have helped me more than once (without making look totally stupid)
and I appreciate it. I write, or try to write code only when I need to.
That give me plenty of time to forget before I need help again!
As I said (above), you and several others do a lot of good helping out!

THANKS MUCH!
Bob

John W. Vinson wrote:
On Tue, 29 Dec 2009 19:45:13 -0500, wrote:

I suspect I am mission out on something here?


Steve is notorious for using these groups to troll for unsuspecting potential
customers. Unlike 99+% of the other volunteers who answer here, he considers
it appropriate to solicit paid business. John (and a few other people) post
responses to these solicitations to warn folks that Steve's proposals should
be carefully examined.

  #14  
Old December 30th, 2009, 04:21 AM posted to microsoft.public.access.gettingstarted
BobC[_6_]
external usenet poster
 
Posts: 89
Default Macro or VB code to Export data to an Excel file?

This is certainly scary!
It worked the first time!
Thank You Very Much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Bob

Arvin Meyer [MVP] wrote:
You can use the Transfer Spreadsheet function on your query. The button code
would be something like:

Private Sub MyButton_Click()
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, "QueryName", _
"C:\Test.xls",, "MyName"
End Sub

Just for your information, acSpreadsheetTypeExcel9 is Excel 97 which should
be readable by later versions, but you can also export to a later format.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.