需要先引入 Microsoft HTML Objects 和 Microsoft Internet Controls
1: Sub login()
2: Dim loginID As String
3: Dim loginPW As String
4: loginID = "myid"
5: loginPW = "mypw"
6:
7: Dim ie As InternetExplorer
8: Dim doc As HTMLDocument
9: Dim element As IHTMLElementCollection
10: Set ie = CreateObject("InternetExplorer.Application")
11: ie.navigate ("http://www.saveonbook.com/post/post.jsp?active=0")
12: ie.Visible = True
13: Do Until ie.readyState = READYSTATE_COMPLETE
14: DoEvents
15: Loop
16: Set doc = ie.document
17: Set element = doc.getElementsByName("LoginPA")
18: element.Item(0).Value = loginID
19: Set element = doc.getElementsByName("PasswordPA")
20: element.Item(0).Value = loginPW
21: Set element = doc.getElementsByName("img23")
22: element.Item(0).Click
23: End Sub
1 則留言:
Hi there,
What if the button has no name but value and onclick.
How do I click the button?
張貼留言