Get Input Elements Name & Type from HTML Form

I came across one more procedure which gets the names of all the inputs on an html page and also the type of inputs and prints on the debug screen. This will help me to get work done by vba rather than someone sitting and doing the same repetitive tasks for hours and days. I would like to thank Dwildman(Senior Member) at ( — Selva V Pasupathy

Option Explicit

Sub GetHTMLControls()
    Dim objIEAs InternetExplorer
    Dim htmlDoc AsMSHTML.IHTMLDocument
    Dim htmlColl AsMSHTML.IHTMLElementCollection
    Dim htmlInput AsMSHTML.IHTMLInputElement
    Set objIE = CreateObject("InternetExplorer.Application")
    With objIE
        .Visible = True
        .navigate ""
        Do While .Busy: DoEvents:  Loop
            Do While .readyState  4: DoEvents: Loop 
                Set htmlColl = .document.getElementsByTagName("INPUT") 
                 ' Check whether I have the right document
                Debug.Print "Doc  name = " & .document.Title
                 ' ***THIS LOOP IS NOT FIRING AT ALL***
                For Each htmlInput In htmlColl
                     Debug.Print "Input element = " & htmlInput.Name & " & Element type = " & _
                Next htmlInput
    End With 
End Sub 


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: