Hello,
I using excel 2010 and access 2010. I have VBA script runtime error 3011 when running script. It has problem finding access report. First I was passing in as variable with the name. Then I used a script to pull in the report name from access and it is still failing with same error.
Code is shown below.
Any help greatly appreciated.
Thank you.
David
-----------
Private Sub Command29_Click()
Dim reportname As String
Dim theFilePath As String, FilePath As String, tempStr As String
' reportname = Me.My_DBTableName I was passing in here, but comment the code out
tempStr = Application.CurrentDb.Containers("Reports").Docume nts(2).Name ' using command pulling in the report name from Access database
reportname = tempStr
theFilePath = Me.My_Export_file_path
theFilePath = theFilePath & reportname & ".xlsx"
' It is failing with code in red
DoCmd.OutputTo acOutputQuery, reportname, acFormatXLSX, theFilePath, True
' I was using the transferspreadsheet command and it was failing for the same reason of not finding report name
' DoCmd.TransferSpreadsheet acExport, 10, reportname, theFilePath, True
MsgBox "Look on your desktop for the report."
End Sub