Solved

Trying to export query data

Posted on 2013-06-11
6
339 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)
Comment Utility
1. no attachment included.

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

Author Comment

by:SteveL13
Comment Utility
Sorry... attachment here.
runtime-error.jpg
0
 
LVL 49

Expert Comment

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

"C:\EmailAddressExport\MyExport.xlsx"

/gustav
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:SteveL13
Comment Utility
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
Comment Utility
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
Comment Utility
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

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…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

744 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

12 Experts available now in Live!

Get 1:1 Help Now