I have some issues to retrieve value from a form or input type. I hope that you could help me or give me some suggestions.
My computer info:
1.window 8.1
2.excel 2013
3.ie 11
My excel reference:
Microsoft Object Library: yes
Microsoft Internet Controls: yes
Microsoft Form 2.0 Object library: yes
Microsoft Script Control 1.0: yes
Expected Result:
retrieve the value "AVrO8qF_" and copy it on Cell ("c2") automatically.
Actual Result:
nothing return to Cell ("C2")
url:
http://coursesweb.net/javascript/getelementsbytagname
Below is the HTML elements.
<form rel="async" ajaxify="/plugins/like/connect" method="post" action="/plugins/like/connect" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)" id="u_0_1"> <input type="hidden" name="lsd" value="AVrO8qF_" autocomplete="off">
Below is my VBA code.
Private Sub CommandButton1_Click()
Dim ie As Object
Dim Doc As HTMLDocument
Dim Elements As IHTMLElementCollection
Dim Element As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = 0
ie.navigate "http://coursesweb.net/javascript/getelementsbytagname"
Do
DoEvents
Loop Until ie.readyState = 4
Set Doc = ie.document
Set Elements = Doc.getElementsByTagName("input")
For Each Element In Elements
If Element.name = "lsd" Then
Range("c2").Value = Element.value
End If
Next Element
Set Elements = Nothing
End Sub
Bookmarks