Auto export to excel

TClark14

Registered User.
Local time
Today, 14:48
Joined
Sep 28, 2001
Messages
85
I am not good with coding at all. Does anyone have code that I can use to attach to a command button that would automatically export a report to excel? It works just like I want manually, but I am trying to reduce the menu options for someone else to only have to click the button, it does the work behind the scene and they just go to excel for the updated report.

THANKS!
 
re:

Hi,
you have to options...either use the OutPutTo Method or the TransferSpreadSheet method. Just use either one the on click event of the command button. Keep in mind that it is normally advised to output the underlying datasource (query/table) instead of the report. Outputting reports is really just for cases you want to keep the visual/graphical representation of the data.
HTH
Good luck
 
Output Report to Excel automatically

I have the following code for the docmd.outputto:

Private Sub Command10_Click()
DoCmd.OutputTo acOutputReport, "rpt2007ScheduleWellListONLY", acFormatXLS, "I:\Drilling Database\rpt2007ScheduleWellListONLY", -1
End Sub

I can see that it is outputting the report to excel as I want it to, but It doesn't open up the excel report automatically which is what I thought the
(-1) was for. I tried replacing -1 with True and it wouldn't work. Also at the end of this code there are two other options, [template file] and [encode] which I ignored because I wasn't sure what to put there. Is this casing it not to open automatically?

THANKS!

Terry
 
DoCmd.OutputTo acOutputQuery, "ADMINQRY_test", acFormatXLS, "C:\TEST.xls"
MsgBox "Your Report has been output to the path below" & vbCrLf & vbCrLf & "C:\TEST.xls", vbOKOnly

This is quite good as it tells the user where the report is..
 
re:

You have to give the outputted file a name + extension e.g.:

DoCmd.OutputTo acOutputReport, "rpt2007ScheduleWellListONLY", acFormatXLS, "I:\Drilling Database\rpt2007ScheduleWellListONLY.xls", True

That should work.
HTH
Good luck
 
That helped me too, thank you.
Just one question - can you specify the output format? eg. excel 2003??
 
re:

Hi,
have a look at the TransferSpreadsheet method.
You can specify what you want in the AcSpreadSheetType argument of the syntax.
HTH
Good luck
 
I am new to ms access, can you please provide me with a sample or a guide line?
 
re:

Click the TransferSpreadsheet link in my initial reply of this thread...it will show exactly what the syntax is and also gives a small sample. Adjust it to fit your needs.
HTH
Good luck
 
Thank you very much - I had a quick look through it!!
Maybe you can help me with one more problem.

If you a manual export, it does not over write the file - it just adds
with the button method it seems to over write - NOT add.

any idea what I can do?
 

Users who are viewing this thread

Back
Top Bottom