MS Access Macro no longer works

Posted on 2013-10-08
Medium Priority
Last Modified: 2013-10-08
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?
Question by:Lev Seltzer
  • 2
  • 2
LVL 17

Expert Comment

by:Barry Cunney
ID: 39555171
Hi WEBuilder,
In the References window, is the check box beside Microsoft Excel 15.0 Object Library ticked on?

Author Comment

by:Lev Seltzer
ID: 39555175
As stated previous, yes, it is ticked on.
LVL 35

Accepted Solution

[ fanpages ] earned 2000 total points
ID: 39555318

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?



Author Closing Comment

by:Lev Seltzer
ID: 39555456
This worked. Thank you for your quick response.
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39555997
No problem at all.

Good luck with the rest of your project.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
What to do if a split doesn't fit? Or a bunch of invoice lines must be rounded while the sum must match a total? It takes a little, but - when done - it is extremely easy to implement.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question