Link to home
Start Free TrialLog in
Avatar of Chuck Wood
Chuck WoodFlag for United States of America

asked on

Microsoft Access VBA The interface is unknown

Reference:
Microsoft Excel 14.0 Object Library

Using this reference, the code below produces the error "The interface is unknown" on the second line of code using Windows 7, Office 14 and Internet Explorer 9. The code runs fine on a second computer with Windows 7, Office 14 and Internet Explorer 8. How can I fix this problem?

Public Function TestExcel()
    Dim xl As New Excel.Application
    xl.Visible = True
End Function
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Is Excel installed?

Jim.
Avatar of Chuck Wood

ASKER

Yes, Excel  is installed and it shows up and is selected in the References.
try this

Public Function TestExcel()
    Dim xl as object
    set xl=createobject("excel.application")
    xl.workbooks.add
    xl.Visible = True
End Function
You define an object variable as a Excel object.
But the xl.Visible = True would assume, that excel is running,
This is what I' missing in you code.
As you stated that the machines are equal (IE doesn't play a role), is it possible that you ested the code with excel running while on the other machine it is not started?
no points please.

I use the same technique Rey used above.
try closing the access app and reopen, then run the codes.
<<Yes, Excel  is installed and it shows up and is selected in the References. >>

 I should have been clearer; certainly it was installed at one time as the reference is there, but is it still installed and working?   Can you open Excel manually and work with it?

More than likely, the registry is fouled up and you'll need to run a repair on Office.  I'd also check your AV and make sure none of the Office files have been quarantined.

Jim.
On the ribbon, select Database Tools then select Visual Basic

The Visual Basic editor will open.

From the menu, select Tools then select References.

Scroll down and ensure Microsoft Excel 14.0 Object Library is selected.
Thank you all for your suggestions.

Ray Obrero:
1. I tried set xl=createobject("excel.application") and it did still has the same error.
2. I have restarted the Access application several times and the code still errors.

Bembi: Dim xl As New Excel.Application starts Excel. I test the code on both machines with Excel not running. The declaration of xl as a new Excel Application starts Excel.

Jim Dettman: Yes, I use Excel regularly and it is working. I will try to repair Office and see if that fixes the registry.

WalkaboutTigger: I have checked the References in the code window and the Microsoft Excel 14.0 Object Library is selected.
As silly as this sounds, deselect it and then reselect it.
WalkaboutTigger:
Good suggestion. I did that when I tried xl=createobject("excel.application") and then went back to Dim xl As New Excel.Application. It still doesn't work. :-)
<<As silly as this sounds, deselect it and then reselect it. >>

That's not silly; it forces VBA to refresh its reference collection.  Often fixes many problems.  

But it sounds like were further along than that.  In some way, the automation interface to Excel is broken.

Jim.
try uninstalling Office, reboot and reinstall/
Jim Dettman:
I ran the Office repair and rebooted but the problem still exists.
will it be too much to uninstall/remove Office, reboot then install ?
Rey Obrero:
I saw your earlier comment and I will probably do that but I will have to wait a week and a half to have our IT folks do that as I cannot have my computer down for that long during that time. I don't think I will get better advice so I am accepting your solution.
I realize you already selected a solution, and am not concerned about that, but one thing you can also check is see if you are getting any DCOM errors in the System or Application event logs.  They may point you to an underlying issue that is actually causing this problem.
WalkaboutTigger:
Thank you for the suggestion. I triggered the problem several times (ran the code) and, unfortunately, there were no DCOM errors in the System or Application event logs.
I would like you to try something.

Exit all other applications and make certain ACCESS.EXE and EXCEL.EXE are not running in Task Manager.

From an elevated command prompt, go to the directory where the Excel.exe file is and type

.\Excel.exe /regserver

This will re-register Excel and its components.
WalkaboutTigger:
Thanks for continuing to try on this issue. I did run the following as an Administrator in a command prompt but it did not fix the problem.
"C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" /regserver
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jim Dettman:

I copied the code into a new Access module and received Run-time error '424': Object required. I  then tried disabling COM add-ins and found disabling "EXCEL and EQD COM Addin" fixed the problem. How can I award point to you?
There should be an "ask Moderator" or similar button on the "Post a comment" form for you, cword, though it may be too late considering the ticket is closed.
Jim Dettman:
I have created a new question, which I will use to award you the points.
And just so you know, cwood, this is how this site is supposed to work.

I won't give up on a question until it is either solved or abandoned.  Many here feel the same way.  It isn't just for you, but for everyone for whom this solution helps.

Respectfully,

WT