使用Excel VBA按网页上的链接

时间:2016-01-19 00:41:00

标签: excel vba excel-vba

我有这个代码,它去了Minecraft.net并输入用户名和密码,然后转到个人资料页面。我需要更改帐户上的密码,该密码将位于工作表的单元格A1中。我似乎无法弄清楚如何点击更改密码链接。到目前为止,这是我的代码:

Dim IE As Object

Sub submitFeedback3()
Application.ScreenUpdating = False

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://minecraft.net/login"

Application.StatusBar = "Submitting"
' Wait while IE loading...
While IE.Busy
    DoEvents
Wend
' **********************************************************************
IE.Document.getElementById("username").Value = "dddddddd"
IE.Document.getElementById("password").Value = "ddd"
IE.Document.getElementById("signin").Click
'**********************************************************************
Application.StatusBar = "Form Submitted"

Set IE = Nothing

Application.ScreenUpdating = True
End Sub

1 个答案:

答案 0 :(得分:0)

如果click不起作用,那么您可以尝试提交html form

' Add reference to Microsoft Internet Controls
' Add reference to Microsoft HTML Object Library

Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate "https://minecraft.net/login"

While IE.Busy
    DoEvents
Wend

IE.Document.getElementById("username").Value = "dddddddd"
IE.Document.getElementById("password").Value = "ddd"

Dim htmlForm As HTMLFormElement
Set htmlForm = IE.Document.getElementById("loginForm")
htmlForm.submit