MS Access Macro no longer works

I received a solution here to create a macro to export a query to a CSV file:
It worked for several years, but some time after install MS Office 2013, it stopped working. I now get the error:
compile error
object library feature not supported

Open in new window

the current code is:
Function ExportUK()
    Dim filepath As String, xlapp As Excel.Application, xldoc As Excel.Workbook
    filepath = "C:\Users\lev\Desktop\ZAKAUK_Donors.xls"
    filepath2 = "C:\Users\lev\Desktop\ZAKAUK_Donors.txt"
    DoCmd.OutputTo acOutputTable, "Recent_UK_Donations", acFormatXLS, filepath
    Set xlapp = CreateObject("Excel.Application")
    Set xldoc = xlapp.Workbooks.Open(filepath)
    xlapp.DisplayAlerts = False
    xldoc.SaveAs filepath2, xlCSV
    xldoc.Close False
    deedCSV = 1
End Function

Open in new window

the line creating the error is:
 Set xlapp = CreateObject("Excel.Application")

Open in new window

Note the Microsoft Excel 15.0 Object Library is Available according to the references window.

How can I make this work again?
Lev SeltzerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Barry CunneyCommented:
Hi WEBuilder,
In the References window, is the check box beside Microsoft Excel 15.0 Object Library ticked on?
Lev SeltzerAuthor Commented:
As stated previous, yes, it is ticked on.
[ fanpages ]IT Services ConsultantCommented:

Please can you try changing this line:

Dim filepath As String, xlapp As Excel.Application, xldoc As Excel.Workbook

To read:

Dim filepath As String, xlapp As Object, xldoc As Object

...and then re-run the code?

Do you see any difference in the outcome?



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lev SeltzerAuthor Commented:
This worked. Thank you for your quick response.
[ fanpages ]IT Services ConsultantCommented:
No problem at all.

Good luck with the rest of your project.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.