SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Exporting to Excel using TransferSpreadsheet


Exporting to Excel using TransferSpreadsheet

Author
Message
GrassHopper
GrassHopper
SSC Veteran
SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)SSC Veteran (275 reputation)

Group: General Forum Members
Points: 275 Visits: 537
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)



WendellB
WendellB
Right there with Babe
Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)Right there with Babe (752 reputation)

Group: General Forum Members
Points: 752 Visits: 1754
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.

Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search