Solved

Trying to export query data

Posted on 2013-06-11
6
342 Views
Last Modified: 2013-06-11
I am trying to export the results of a query with:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDistinctEmailAddresses", "C:\EmailAddressExport", True

but am getting a runtime error (see attachment)

Also, instead of exporting the Excel file to the user's C drive I want it to go to the user's desktop.
0
Comment
Question by:SteveL13
6 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39237981
1. no attachment included.

2.  Try adding a file extension (.xlsx) to the output file name
0
 

Author Comment

by:SteveL13
ID: 39238077
Sorry... attachment here.
runtime-error.jpg
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39238134
You only have the path. A filename is needed too, like:

"C:\EmailAddressExport\MyExport.xlsx"

/gustav
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:SteveL13
ID: 39238359
Now I have this...

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDistinctEmailAddresses", "C:\EmailExport\EmailAddresses.xlsx"

But when I try to open the Excel file I get the attached error.

??
error2.jpg
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39238441
Seems like you don't have the correct version of Excel.
Try to create an older *.xls file with:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryDistinctEmailAddresses", "C:\EmailExport\EmailAddresses.xls"

/gustav
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39238521
if you are using A2003, use this

DoCmd.TransferSpreadsheet acExport, 8, "qryDistinctEmailAddresses", environ("userprofile") & "\Desktop\EmailAddresses.xls", True

if you are using A2007 or greater use this

DoCmd.TransferSpreadsheet acExport, 10, "qryDistinctEmailAddresses", environ("userprofile") & "\Desktop\EmailAddresses.xlsx", True
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now