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

  • Thread starter Thread starter BobC
  • Start date Start date
B

BobC

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
 
Take a look at the TransferSpreadsheet function in the Help file.

Steve
(e-mail address removed)
 
Before proceding, post your relevant tables and I will analyze and comment.

Steve
(e-mail address removed)
 
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.
 
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.
 
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.
 
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
 
This is certainly scary!
It worked the first time!
Thank You Very Much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Bob
 
Back
Top