[英]Trying to automate data entry on a sap webapp using IE and excel vba
I am able to log in however, I am not able to select any options from there.但是,我可以登录,但无法从那里选择任何选项。
Tried reading on UI Automation however couldn' follow, can someone help to code for click尝试阅读 UI 自动化,但无法理解,有人可以帮助编写点击代码吗
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://website.com/"
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
IE.document.getElementById("j_username").Value = "user"
doc.getElementById("j_password").Value = "pass"
doc.getElementById("logOnFormSubmit").Click
Do While IE.Busy
Application.Wait DateAdd("s", 10, Now)
Loop
Dim NewTicketBtn As Object
Set NewTicketBtn = doc.getElementById("__tile0-__component0---landingDetail--aboPanel-2")
NewTicketBtn.Click
Try this.尝试这个。 Read my comments in the macro:
阅读我在宏中的评论:
Sub test()
Dim IE As Object
Dim doc As HTMLDocument
Dim NewTicketBtn As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://website.com/"
Do While IE.Busy: DoEvents: Loop
Set doc = IE.document
doc.getElementById("j_username").Value = "user"
doc.getElementById("j_password").Value = "pass"
doc.getElementById("logOnFormSubmit").Click
'This don't work here because the ready state of the IE is allready 'complete'
'Do While IE.Busy
'Application.Wait DateAdd("s", 10, Now)
'Loop
'
'You must set a manual break for a few seconds to load the page after the login
'If 3 seconds not enough go higher
Application.Wait (Now + TimeValue("0:00:03"))
'Here you can't work anymore with 'doc' because the document in the IE has changed
Set NewTicketBtn = IE.document.getElementById("__tile0-__component0---landingDetail--aboPanel-2")
NewTicketBtn.Click
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.