[英]Trying to automate data entry on a sap webapp using IE and excel vba
但是,我可以登錄,但無法從那里選擇任何選項。
嘗試閱讀 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
嘗試這個。 閱讀我在宏中的評論:
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.