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 (http://www.ozgrid.com/forum/showthread.php?t=74589) — Selva V Pasupathy

Option Explicit

Sub GetHTMLControls()
'This procedure requires MICROSOFT INTERNET CONTROLS AS A REFERENCE  
    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 "https://www.wordpress.com/login/"
         
        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 = " & _
                                    htmlInput.Type
                Next htmlInput
    End With 
End Sub 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: