Solved

Trying to export query data

Posted on 2013-06-11
6
347 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

777 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