0

I want to open a web page directly from Excel VBA where I need to click on the "active directory" button which has no ID. This button uses the Windows credentials to automatically log so I just need to click there to later once I'm logged I can start populating some fields.

This generic code is giving me an error message

" The object invoked has disconnected from its clients"

I assume it's related to the web page secure log on.

Sub test()
    Const sSiteName = "https://www.padb.ford.com/PadbStrutsWeb/treeHomePre.do"
    Dim oIE As Object
    Dim oHDoc As HTMLDocument
    
    Set oIE = CreateObject("InternetExplorer.Application")
    
    With oIE
        .Visible = True
        .navigate sSiteName
    End With
    
    While oIE.readyState <> 4
        DoEvents
    Wend
 
    Set oHDoc = oIE.document
    
    With oHDoc
'Here I want to click on that button so I can latter populate some of the fields, once page is loaded'

    End With

End Sub
Community
  • 1
  • 1

1 Answers1

0

IE is EOL and shouldn't be used anymore.

I can't tell you how exactly on the page the button is clicked, because that requires the HTML code. But the disconnection from the client may be due to the way IE is initialized. Try it via the GUID D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E

Sub test()
  Const sSiteName = "https://www.padb.ford.com/PadbStrutsWeb/treeHomePre.do"
  Dim oIE As Object
  Dim oHDoc As HTMLDocument
  
  Set oIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
  
  With oIE
    .Visible = True
    .navigate sSiteName
  End With
  
  While oIE.readyState <> 4
    DoEvents
  Wend
  
  Set oHDoc = oIE.document
  
  With oHDoc
    'Here I want to click on that button so I can latter populate some of the fields, once page is loaded'
  End With
End Sub
Zwenn
  • 2,147
  • 2
  • 8
  • 14
  • Hi Zwenn,Seems like your solution actually avoids that error message, thanks a lot!! If I may ask another question, seems like internet explorer is going to be removed from my company computer this year, so I wanted to ask if there´s a way to use this code to open chrome or Edge instead of Internet explorer? – Ro Velázquez Mar 14 '22 at 21:45
  • @RoVelázquez There is no direct way to interact with a browser other than IE from VBA. But you can install the SeleniumBasic framework (if you are allowed) to interact with Chrome from VBA. YasserKhalil has explained here in the accepted answer what to do to be ready to use it. The syntax is another question: https://stackoverflow.com/questions/57216623/using-google-chrome-in-selenium-vba-installation-steps – Zwenn Mar 14 '22 at 22:48
  • Thank you very much Zwenn, I do have heard of Selenium but sadly I wont be allowed to install external tools. Thanks for sharing your knowledge – Ro Velázquez Mar 15 '22 at 01:03
  • I think may be related `https://gurupackager.blogspot.com/2014/05/integrity-levels-and-internet-explorer.html` to above solution. – QHarr Jun 10 '22 at 06:43