VBA programming error: runtime error '-2147417848 (80010108)'

Asked

Viewed 540 times

0

Hello,

I’m trying to make a macro with VBA to automate a process in the company I work in. For this the macro should open the IE and enter the website of the company portal.

Follow the code written inside a Module:

    Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long        

    Sub Teste1()

            Dim ie As Object

            Set ie = CreateObject("internetexplorer.application")
            ie.Navigate ("https://portaldeacessos.visanet.corp/IDMProv/jsps/login/Login.jsp")
            ie.Visible = True
            ShowWindow ie.hwnd, 3
            While ie.Busy
                DoEvents
            Wend

            For Each l In ie.Document.GetElementsByID("user")
                l.Value = "teste"
            Next

        End Sub

The problem is I can’t get her to interact with anything. Anything I try to do after entering the portal site gives the error "The 'Document' method of the 'Iwebbrowser2' object failed". But I know that this part below is correct because I’ve used in another macro that worked.

While ie.Busy
    DoEvents
Wend

When I mark the FOR line to debug, I wait for the page to load and give F8, this other error occurs: "Automation error. The object was disconnected from its customers".

When I run the same program replacing the portal site with google, I can write in the Google search box without errors

My focus is on being able to resolve the "disconnected from your customers" error because it has been appearing more frequently. Does anyone know how to do?

Thank you

  • Turn off Protected mode inside the Security tab in Internet Explorer. Should be sufficient.

  • I checked that the protected mode was already disabled. You happen to have some other solution?

2 answers

0

Hello!

This is a very common problem and is related to the level of integrity at which Internet Explorer (IE) is configured.

An alternative that usually works, using the above code is to replace the

Set ie = CreateObject("internetexplorer.application")

for

Set IE = New InternetExplorerMedium

If it still doesn’t work, please let me know.

-2

I just found out, in my case I entered the code below: Application.Wait Timeserial(Hour(Now()), Minute(Now()), Second(Now()) + 2)

It’s because he wasn’t expecting to load the page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.