I have a small piece of code that is supposed to write out a REPORT in to an Excel file in Excel format and open the document in Excel.
It works fine in witht he command that is now commented out. But with a similar command for Access 2007 does not perform the smae thing. The code that I am using now for Access 2007 does not work.
Code:
Here is the complete code.
Code:
Can someone please tell me what command that i should use in Access 2007 (on Vista) to write out or save a report in an Excel file and open the file automatically.
It works fine in witht he command that is now commented out. But with a similar command for Access 2007 does not perform the smae thing. The code that I am using now for Access 2007 does not work.
Code:
Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "NewEmailList"
Code:
Code:
Public Function ExportEmailList()
Dim Filename As String
' Get the Current Path and Make up the file name
Filename = Application.CurrentProject.Path & "\NEW_Email_List_" & Format(Date, "yyyymmdd") & ".xls"
MsgBox "Writing Email list to File-" & Filename
'Generate the report in the proper format with names concatenated. For Access 2003. Not for 2007.
'DoCmd.OutputTo acOutputReport, "rptNewEmailList", acFormatXLS, Filename, -1
' For Access 2007
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "NewEmailList", Filename, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "NewEmailList", "NEW_Email_List_" & Format(Date, "yyyymmdd") & ".xls", True
MsgBox "Completed Writing Email list"
End Function