Darkcloud617
New Member
- Joined
- Sep 7, 2017
- Messages
- 38
I have a code that logs in to a website as it should but when it goes to click into a drop down menu it errors "Method 'Document' of object 'IWebBrowser 2' failed" and errors on this line
Here is the full code:
This is a snip of the website code that contains the menu I am trying to click:
I am trying to get VBA to click the last option "All Open Orders in view" but I think I'm getting confused because its a hover drop down menu. When hovering over the box on the website the javascript code changes to "MenuBar_Menu_Item Menu_Item_Hover" from "MenuBar_Menu_Item". I'm not sure how to account for that.
Any help would be greatly appreciated. Thank you.
VBA Code:
IE.Document.getElementsByClassName("MenuBar_Menu")(1).Click
Here is the full code:
VBA Code:
Sub test()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With CreateObject("InternetExplorer.Application")
Dim chng As Object, chk As Object
.Visible = True
.Navigate "https://www.google.com"
While .Busy Or .ReadyState <> 4: Application.Wait (Now + TimeSerial(0, 0, 1)): Wend
Set chng = .Document.createEvent("HTMLEvents")
chng.initEvent "change", True, False
.Document.getElementById("txtEmail").Value = "XXXX"
.Document.getElementById("txtPassword").Value = "XXXXX"
.Document.getElementById("Main_Main_btnSignIn").Click
Application.Wait (Now + TimeValue("0:00:10"))
IE.Document.getElementsByClassName("MenuBar_Menu")(1).Click
End With
End Sub
This is a snip of the website code that contains the menu I am trying to click:
I am trying to get VBA to click the last option "All Open Orders in view" but I think I'm getting confused because its a hover drop down menu. When hovering over the box on the website the javascript code changes to "MenuBar_Menu_Item Menu_Item_Hover" from "MenuBar_Menu_Item". I'm not sure how to account for that.
Any help would be greatly appreciated. Thank you.