VBA 및 HTML을 사용하여 Internet Explorer 창에서 단추를 클릭하려고합니다. 버튼에는 "id"가 없으므로 "classname"으로 찾아야합니다. 다음과 같이VBA (getElementsByClassName)를 사용하여 Internet Explorer에서 버튼을 클릭하십시오.
버튼의 HTML 코드는 다음과 같습니다
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only`"
VBA 코드 :
Private Sub CommandButton21_Click()
Const cURL = "xxxxxx.com"
Const cUsername = "xxxxxx"
Const cPassword = "xxxxxx"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim CVBATButton As HTMLInputButtonElement
Set IE = New InternetExplorer
IE.Visible = True
IE.navigate cURL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set doc = IE.document
'A previous login window that leads me into a new window, where I need to click a button.
Set LoginForm = doc.forms(0)
Set UserNameInputBox = doc.getElementById("BIA_Login")
UserNameInputBox.Value = cUsername
Set PasswordInputBox = doc.getElementById("BIA_Pass")
PasswordInputBox.Value = cPassword
Set SignInButton = doc.getElementById("login")
SignInButton.Click
'It's this portion of the code below that I'm struggling with
Set doc = IE.document
Set LoginForm = doc.forms(0)
Application.Wait Now + TimeValue("00:00:03")
Set CVBATButton = doc.getElementsByClassName("ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only")
CVBATButton.Click
은 그래서에서 getElementById가 배열 점에서 getElementsByClassName에서 후자의 수익을 다른 것을 이해하고 내가 액세스 필요 :
– Davey(1) VBA 것은 무엇입니까? – elfwyn
@elfwyn 예, 배열에서 첫 번째 요소를 얻는 방법입니다. – 4castle