=========
QUESTION
———
How do I export to a spreadsheet using VBA?

 

=========
ANSWER
———
See EXAMPLES

 

=========
EXAMPLES
———
MyFilePath = “C:Test”
Me.Status = “Creating Spreadsheet file”
Me.Repaint
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, “ReportOrQueryName”, MyFilePath & “FileName.xls”

———
Me.CurrentStatus = _
“Exporting to Excel for Distribution” & vbCrLf & _
Now() & vbCrLf & _
vbCrLf & _
Me.CurrentStatus

Dim MyPath As String

rstPrm = CurrentDb.OpenRecordset(“0000T_Parms”)
MyFile = “U:StorSaleSystemsPMEvents2014Fisc050_MCCP_20140126_20140426ResultsGoalsEtcPM_CustGrw_WklyRslts_” & rstPrm!BackupSerial & “_” & Format(Date, “yyyymmdd”)

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, “5030_PrcOfGl_Feb_US_DM”, MyFile, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, “5040_PrcOfGl_Feb_CN_DM”, MyFile, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, “5050_PrcOfGl_Feb_US_ADM”, MyFile, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, “5060_PrcOfGl_Feb_CN_ADM”, MyFile, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, “5010_PrcOfGl_Feb_US”, MyFile, True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, “5020_PrcOfGl_Feb_CN”, MyFile, True

Me.CurrentStatus = _
“Export to excel complete” & vbCrLf & _
Now() & vbCrLf & _
vbCrLf & _
Me.CurrentStatus

=========
APPLIES TO / KEY WORDS
———
Access
VBA
Excel
Spreadsheet
Export
VBA Export to Excel

 

=========
REF
———

 


http://www.anysitesupport.com/access-vba-export-to-spreadsheet/
http://anySiteHosting.com