exporting to Desktop?

  • Thread starter Thread starter peg
  • Start date Start date
P

peg

I am looking to do an export of data to an excel file - but I want the file
to be saved to the user's desktop - how do I do that??

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"tbl3tierClientBenefits", [desktop code] &"\3TierBenefits.xls", True
 
Get the code to retrieve special folder locations from the following URL ...

http://www.mvps.org/access/api/api0054.htm

Once you have that code, you use it like so ...

Public Sub Transfer2Desktop()

Dim strPath As String

strPath = fGetSpecialFolderLocation(CSIDL_DESKTOP)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel3, "tblA",
strPath & "\test.xls", True

End Sub

Keep in mind, though, that in Windows XP, users can choose not to display
any icons on the desktop. (Right-click the desktop, choose Arange Icons By
...., then Show Desktop Icons). So your exported file may be invisible to the
user.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top