Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Exporting to Excel using TransferSpreadsheet Expand / Collapse
Posted Tuesday, July 29, 2014 3:35 PM


Group: General Forum Members
Last Login: Monday, November 7, 2016 11:31 AM
Points: 189, Visits: 534
I have the code below that exports data to an excel file and creates a tab for each query ran. If It runs more than 5 TransferSpreadsheet commands then It error outs with Error 3011. It is not consistent. Sometimes it runs but other times it fails. It is in a Loop and it runs the line below 6 times and it bombs on me. Can't figure it out....

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Export_Query", Forms(currentform).Browse_LocationLabel.Caption & "\" & rs_grpid![GroupID] & "_" & rs_grpid![VendorName] & "_" & rs_grpid![VendorNumber] & ".xlsx", True, a_arr(i_arr)

Post #1597513
Posted Saturday, August 2, 2014 8:21 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 9:07 AM
Points: 237, Visits: 1,589
Your 3011 error indicates that Access cannot find the object being specified in the statement. Since you are using variables, I would suspect that the path to where you are trying to export the Excel workbook to doesn't exist. To verify that you can put in some code to trap the error and display the variables being used to construct the path.

If that turns out not to be the case, another more remote possibility is an issue with the TransferSpreadsheet method in your version. Export capabilities were reworked extensively in 2010 and were problematic until SP1 was released, but they still seem to experience occasional issues even with 2013 in my experience.

Colorful Colorado
You can't see the view if you don't climb the mountain!
Post #1598937
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse