Compile Error- Expected: Expression
DoCmd.TransferSpreadsheet acExport,acSpreadsheetTypeExcel9,"Subcycle
Data",,True,,,
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Ann B" <An...@discussions.microsoft.com> wrote in message
news:7A26E4A1-B323-4424...@microsoft.com...
1) You haven't told Access into what spreadsheet to export the data.
2) If you have no arguments to use after your last argument (i.e.
True,,,), you do not need to add commas.
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Subcycle
Data", "c:\MyFolderName\SpreadsheetName.xls", True
The above will transfer your query data into a worksheet named
"Subcycle Data" in a spreadsheet named "SpreadsheetName.xls" in the
folder "MyFolderName".
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
I suppose you could use "C:\Documents and Settings\All Users\My
Documents\book1.xls", or you can grab the code from
http://www.mvps.org/access/api/api0008.htm at "The Access Web" and use
"C:\Documents and Settings\" & fOSUserName & "\My Documents\book1.xls" or,
even better, grab the code from http://www.mvps.org/access/api/api0054.htm
and use fGetSpecialFolderLocation(CSIDL_PERSONAL) & "\book1.xls"
If you need to know whether or not the file already exists, you can use the
Dir function:
If Len(Dir(strFileLocation)) > 0 Then
' The file exists. Prompt the user to delete.
If MsgBox(strFileLocation & " already exists." & _
"Do you want to delete it?", vbYesNo + vbQuestion) = vbYes Then
Kill strFileLocation
End If
End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Ann B" <An...@discussions.microsoft.com> wrote in message
news:F5DE56AA-BC90-4054...@microsoft.com...
In Access, don't open the query at all. The TransferSpreadsheet will,
behind the scenes, run and transfer the data. You won't see it.
To then open the spreadsheet (after transferring the data) add one
line of code:
Application.FollowHyperlink "c:\MyFolderName\SpreadsheetName.xls"
Of course, change the path to whatever your actual spreadsheet path
is.
Then click on the worksheet, if there is more than one in the
workbook.