Excel Vba runtime error '-2147467259 (80004005)'

I get Run-time error '-2147467259 (80004005)': Automation error

Excel VBA Code:

Sub Test4()
    Dim url As String
    Dim ie As Object
    url = "https://www.google.com/?gws_rd=ssl"
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True

    ie.navigate url

    Set ie = nothing

End Sub

Error occurs when executing the CreateObject command.

The following VBA Library References are checked:
 Visual Basis for Applications
 Microsoft Excel 16.0 Object Library
 OLE Automation
 Microsoft Office 16.0 Object Library

Running Windows 7, SP1; Office 16.0

How do I avoid getting this error?

I'm running Win7 x64 with SP1. Office Pro Plus 2016 x32.

I just created a new workbook, added a code module, and plugged in your code (changing only the URL, to "https://www.google.com/")

It opened an IE window without issue. Note that I'm in a corporate environment that sometimes has delays in rolling out office patches, so if you are fully patched then our environments will be slightly different.

Are your OS and office x32 or x64? What else can you tell us about your configuration? Do you use VBA regularly, and this is a new problem?

 

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Okay I did not tell the full story.  I call the macro several times from another macro.  After about 60 calls, I get the error. 

The URL shown is not the one that I actually use, but that does not matter because the error occurs on the line,
Set ie = CreateObject("InternetExplorer.Application").  Also, I do not have the line ie.Visible =True in my actual code.

So the problem is I can only call "Set ie = CreateObject("InternetExplorer.Application")" so many times before it stops working.  Also, if I close Excel and then reopen it, it still will not execute the Set ie command.  The only way to clear the problem is to close Windows altogether and reboot.  After I reboot, I can then execute "Set ie = CreateObject("InternetExplorer.Application")" .

I think this is a Windows system problem; not an Excel issue.  I think Windows must not close down the IE process even though the
"Set ie = nothing" is executed each time.  I tried putting "ie.quit" in the macro, but VBA says that command is invalid.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

IE.quit would have been my next suggestion. Are you using that before, after, or instead of the set IE= nothing line? Same error regardless?

Otherwise, you might research API calls or iterate (backward) through all IE windows (shell.windows?) to try to force them to close.

Just to confirm, all of this code is in the same sub, or ie is declared as global?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I take it back.  The ie.quit does work.  When I use it, I no longer get the error.  Here is the full trial code:

-----------------------

Sub Test1()
    Dim N As Integer
    Sheets(1).Select
    N = 0
    While N < 200
        Call Test4
        N = N + 1
        Cells(1, 1) = N
    Wend
End Sub
Sub Test4()
    Dim url As String
    Dim ie As Object
    url = "https://www.google.com/?gws_rd=ssl"
    Set ie = CreateObject("InternetExplorer.Application")
    DoEvents
    ie.Quit
    ie.navigate url
End Sub

----------------------------

If I comment out the line ie.quit, then I get the error after 64 iterations.  If I leave the ie.quit line in, I do not get any errors.  One thing I noticed is that if I leave out the DoEvents line, sometimes I get errors when it executes the ie.quit statement.

Thanks for your help.  The problem is solved.
Jim

4 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 13, 2025 Views 24,541 Applies to: