【发布时间】:2016-06-09 18:07:02
【问题描述】:
我正试图让我的宏让我登录到一个网站。到目前为止,我已经输入了我的用户名和密码,但我不知道如何让它“点击”按钮。该网站是https://www.aum-inc.com/log-in,登录按钮不是我知道如何激活的那种。它有某种javascript。下面是我的代码,其中 HELP 由我需要针对这种特定情况更新的两行编写。
Sub AUM()
'we define the essential variables
Dim ie As Object
Dim pwd, username
Dim button
'add the "Microsoft Internet Controls" reference in your VBA Project indirectly
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate ("https://www.aum-inc.com/log-in")
While ie.ReadyState <> 4
DoEvents
Wend
Set username = .document.getElementById("cphContent_C001_txtUserName") 'id of the username control (HTML Control)
Set pwd = .document.getElementById("cphContent_C001_txtPassword") 'id of the password control (HTML Control)
'HELP Set button = .document.getElementById("ctl00$cphContent$C001$btnPropLogon") 'id of the button control (HTML Control)
username.Value = "Account1234"
pwd.Value = "Password1234"
'HELP button.Click
While ie.ReadyState <> 4
DoEvents
Wend
End With
'insert some sort of code in VBA to find account
Set ie = Nothing
结束子
【问题讨论】:
-
试试,ie.document.getElementsbyName("btnsubmit")(0).click.
标签: javascript excel vba macros