?
Solved

Access Report export question: DoCmd.OutputTo can't export Excel 1997-2003 format?

Posted on 2010-01-10
11
Medium Priority
?
899 Views
Last Modified: 2012-08-14
This is a big problem for me and I hope it's resolvable:

I wanted to automate the saving process of Access reports by using DoCmd.OutputTo:
 DoCmd.OutputTo acOutputReport, "rptTemplate", acFormatXLS, "sample.xls"

In the mean time, we could manually export the report after opening it by choosing either:
"Excel 5-7" or "Excel 1997-2003".

Unfortunately, I found DoCmd.OutputTo could only export "Excel 5-7" format.

Seems I could not use DoCmd.TransferSpreadsheet  for Access Reports and I do not want to change registry settings. Is there any workaround if I use DoCmd.OutputTo command? What's the fix for this problem if I really want to automatically export report in "1997-2003" format?

Thanks a lot!
0
Comment
Question by:heyday2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 400 total points
ID: 26276739
Why can't you use Transferspreadsheet?
0
 

Author Comment

by:heyday2004
ID: 26276798
Sorry you are right, I had thought Transferspreadsheet could only be used on tables. But still, how could I use Transferspreadsheet  to do the exact thing of:  DoCmd.OutputTo acOutputReport, "rptTemplate", acFormatXLS, "sample.xls"? Any detailed answer is appreciated. Also, which way is better? Thanks a lot.
0
 

Author Comment

by:heyday2004
ID: 26277085
Seems not working:

I got this error:
Error: Run-time error '3011'
The Microsoft Jet Database engine could not find the object 'rptTemplate'. Make sure the object exists and that you spell its name and the path name correctly.

The command I was using is:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "rptTemplate", "C:\temp\test.xls", True

Seems it's a big problem for me to export Access Report to Excel 2003 format using these commands. Any help is really appreciated. Thanks a lot.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1600 total points
ID: 26277538
you  will use the report recordsource ( queryName or TableName) instead of the name of the report nname.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "queryName", "C:\temp\test.xls", True

0
 

Author Comment

by:heyday2004
ID: 26278927
But my report record source is like:query1
and I have a filter like statement for the final report: [Customer_Code] = txtCode.Text

How could I put the filter statement in my TransferSpreadsheet command?

Thanks for any further help.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1600 total points
ID: 26279619
are you exporting the report from the same form where the txtCode is?
0
 

Author Comment

by:heyday2004
ID: 26279812
yes, report query is query1, but i have a loop to read each a list of txtCodes, and each txtCode is a filter, and the report is based on the query1 and this txtCode filter (the query1 is too big). Thanks.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1600 total points
ID: 26279823
try adding a where clause to your query1

where  [Customer_Code] = Forms!NameOftheForm!txtCode


change < NameOftheForm > with the actual name of the form.
0
 

Author Comment

by:heyday2004
ID: 26280097
Thanks, but seems it still has big problem:

I did get the exported excel file after revising the query1. But the file is purely an export of SQL query: query1, and loses all the report formats. What I really need is the exported excel file from the report like below command (specifying report type):
DoCmd.OutputTo acOutputReport, "rptTemplate", acFormatXLS, "sample.xls"?

Any hint is appreciated. Thanks a lot.

0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1600 total points
ID: 26280194
try this,  use
DoCmd.OutputTo acOutputReport, "rptTemplate", acFormatXLS, "sample.xls"

to create the excel file
open the excel fle "sample.xls"
try saving as "Excel 1997-2003"

was it saved as in "Excel 1997-2003"?
if it was, we can do this in codes.
0
 

Author Comment

by:heyday2004
ID: 26280280
Good idea. But seems still having problems:

DoCmd.OutputTo acOutputReport, "rptTemplate", acFormatXLS, "sample_excel_5-7.xls"

This will create excel file in "Excel 5-7" format, which is the same as right click "Export" on the report, and then choose "Excel 5-7", the file size is both: 34kb

But when I saved this file as you said as "Excel 1997-2003": sample_excel_1997_2003_VBA.xls, the file size is 60kb

While when I right click the report and manually export it as Excel 1997-2003 format: sample_excel_1997_2003_Manual.xls, the size is 41kb.

All these files seems to be identical (format, data, line number, etc.) when I opened them in Excel 2003.

Thanks for any further help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question