Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-01-10
11
Medium Priority
?
905 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
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

580 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