Avatar of dsoderstrom
 asked on

Problem with GetObject function in MS Access

I am trying to open excel  from vba code in Access 2010 using the GetObject function.
My code is as follows:
      dim xlObj as Object
      Set xlObj = GetObject(, "excel.application")

I get the following error  on the second line:

      Run-time error '429':
      ActiveX component can't create object

What is strange is that this was working for a few iterations and now it doesn't.
The first time if failed I did a decompile of the data base and that got it to work for one time.  But then if failed with the same message again.

Any ideas on what is causing this?
Microsoft Access

Avatar of undefined
Last Comment
Dale Fye

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Wow, I guess that should have been obvious to me!
Thank you for the help.
Dale Fye

Generally, I put an error handler at the beginning of the code module.

Then I use the GetObject syntax to set the reference to an existing instance of Excel.  If that raises an error, it goes to the error handler, where I use syntax similar to:

If Err.Num = x  then   'don't remember the error code off the top of my head
    Set xlObj = CreateObject("Excel.Application")
    Resume Next

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck