Run time error 31532- Microsoft Access cannot export the data.

amit_excelVBA

New Member
Joined
Apr 11, 2019
Messages
4
Hi, I am using below code to export table from access 2016 to excel but getting error saying:

Run time error 31532: Microsoft Access cannot export the data


Public Function ExportToexcel_DD()

Dim output_fl As String


stName = "\PRO"
output_fl = CurrentProject.Path & stName & "_DROPS.xlsx"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, TableName:="Dps_Arprts", FileName:=output_fl, Hasfieldnames:=True, Range:="Arpts"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Dps_Rnws", output_fl, True, "Rnws"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Dps_Obs", output_fl, True, "Obs"

End Function

Please help
Thanks in Advance.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I cant reproduce the error, is it exporting a table or a query?

From google it looks like a lot of people who have had it put it down to Xml.

What happens if you change to:

Code:
[COLOR=#333333]Public Function ExportToexcel_DD()[/COLOR]

[COLOR=#333333]Dim output_fl As String[/COLOR]


[COLOR=#333333]stName = "\PRO"[/COLOR]
[COLOR=#333333]output_fl = CurrentProject.Path & stName & "_DROPS"[/COLOR]

[COLOR=#333333]DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, TableName:="Dps_Arprts", FileName:=output_fl, Hasfieldnames:=True, Range:="Arpts"[/COLOR]
[COLOR=#333333]DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Dps_Rnws", output_fl, True, "Rnws"[/COLOR]
[COLOR=#333333]DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "Dps_Obs", output_fl, True, "Obs"[/COLOR]

[COLOR=#333333]End Function[/COLOR]
 
Upvote 0
Sure, the first thing whenever the versions of MS OFFICE tools is changed we need to check the reference of the vba library. I checked and activated below references from references under Tools menu in VBA section.

Microsoft Office 16.0 Access database engine object library

Microsoft office 16.0 Object Library

Microsoft Access 16.0 Object library.
 
Upvote 0
Thank you.
No mention was made in the original post of an upgrade to Office. so that would not be a solution easily thought of.?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top