This simple method exports to an excel format, but in your case, just use the TranserText arguments. This sample refers to two textboxes on a form. In this case the path is chosen from a popup browse dialog, as Zameer suggested, and the file name is entered by the user.
Dim strPath As String
strPath = Me.txtPath
Dim strFileName As String
strFileName = Me.txtFileName
Dim strFullPath As String
strFullPath = strPath & strFileName
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryName", strFullPath
-----------------------------------------------
But if you want to hard coded the location, you can use strPath = "c:\somewhere\"(not recommended), or pick up the location path by referencing a form control, which can come from your query.
Mike Dorthick