ExportExcel Menu button to Form.

pikoy

Registered User.
Local time
Today, 05:15
Joined
Dec 23, 2009
Messages
65
Good PM Access World,

Just wondering if there is a way to put the Export to Excel Spreadsheet (ExportExcel) menu button onto a form.

say "DoCmd.ExportExcel" kind of thing.

--- I had created a ribbon that will hide the menu bar, office button and QAT... I want the ExportExcel function to live in the form.... is this possible?

I tried the Transferspreadsheet thing.... but that does not work for what i want it to do. Also, i can also see that i need to revise my ribbon to have it available... but besides these things. Is there a way for that ExportExcel menu button to live on the form?

thank you
 
Since Transferspreadsheet doesn't work for you, what do you need it to do?

If you want to mimic the button, I believe you would want this command on the button -
Code:
DoCmd.RunCommand acCmdOutputToExcel

But the object you are exporting would need to be the active object (which would mean the form with the button on it. If you had something else you wanted you could try to use this together with it:
Code:
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdOutputToExcel
(using that code exactly without changing anything)
 
Since Transferspreadsheet doesn't work for you, what do you need it to do?

If you want to mimic the button, I believe you would want this command on the button -
Code:
DoCmd.RunCommand acCmdOutputToExcel

But the object you are exporting would need to be the active object (which would mean the form with the button on it. If you had something else you wanted you could try to use this together with it:
Code:
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdOutputToExcel
(using that code exactly without changing anything)

Thanks for the Reply SuperBob.

It still doesn't quite do it.

Maybe a little background. I have a report thats passess through a filter... by clicking the menu button "ExportExcel", the filtered report is exported to excel and only exports the filtered values. Now that I took out the ribbon, that button is unavailable... and wanted to mimic the same functionality.

I had tried a Macro (residing on the onclick on a button) and it exports everything on that resides on the query; same results on the TransferSpreadsheet.

The only solution I can think of is to revise the ribbon. I was wondering if there are any available solutions before I revise the ribbon - I dont like to revise the ribbon.

Thanks again for the reply SuperBob.
 
Don't use a macro, use the code I gave you directly. And you have to have the report open and filtered first. So I take it you are wanting a formatted Excel output, is that right?
 
You could also try manually exporting the report to Excel and when finished Access will ask you if you want to save the steps (2007 onwards) say Yes and give it a name then on your button

Code:
DoCmd.RunSavedImportExport "YouSavedNameHere"
 
Thank you again. Formated output worked. I am really glad I found this site... More power and ofcourse... big thanks to the experts, admins and mods.
 

Users who are viewing this thread

Back
Top Bottom