HTA VBScript - IE CreateObject(InternetExplorer.Application) IE.Document.form1 doesn't support property or method

Jim picture Jim · Sep 4, 2012 · Viewed 17.1k times · Source

I've done this a few times, however I'm not sure why this time my HTA vbscript is yelling at me about Object doesn't support this property or method IE.Document.form1?

Ignore the Wait IE,2000 subs.

Function server_details(server_name)
    dim returnArray(6)

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://website/Default.aspx"
    Wait IE,2000
    With IE.Document.form1
        .txtServerName.value = server_name
        .Button1.click
    End With

    Wait IE,4000

    'get info returned
    With IE.Document.all
        serverOS = .txtOS.value
        serverApp = .txtBusinessApp.value
        serverClass = .txtServerClass.value
        serverHost = .txtHost.value
        serverEnv = .txtSupportEnvironment.value
        serverCheckout = .txtCheckoutStatus.value
    End With

    IE.Quit
    Set IE = Nothing
    returnArray(0) = serverOS
    returnArray(1) = ServerApp
    returnArray(2) = serverClass
    returnArray(3) = serverHost
    returnArray(4) = serverEnv
    returnArray(5) = serverCheckout
    server_details = returnArray
End Function

I have this function in my HTA vbscript as well, and it works fine.

Function subnetDetails(server_ip)
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = False
    IE.Navigate "http://otherwebsite/detail.aspx"
    Wait IE,2000
    With IE.Document.aspnetForm
        .[ctl00$_SUMMARY$txtIP].value = server_ip
        .[ctl00$_SUMMARY$btnLoad].click
    End With

    'webscrape for TABLE id="ctl00_SUMMARY_gvSubnets"
    Wait IE,9000
    responseHTML = IE.Document.getElementByID("ctl00_SUMMARY_gvSubnets").outerHTML
    IE.Quit
    Set IE = Nothing

    subnetDetails = responseHTML
End Function

Found that form1 is in an iframe, might be why i can't reference it. Any ideas?

<iframe id="ctl00_ContentPlaceHolder1_I1" bordercolor="White" name="I1" src="CSIS.aspx" style="border-style: none; overflow: auto; height: 2500px; width: 1100px;" frameborder="no" scrolling="no">

<html>
    <head>
        <body>
            <form name="form1" bla bla"


 </iframe>

Answer

Jim picture Jim · Sep 4, 2012

Ok, so figured it out. The iframe was causing all the trouble. For those with the same error message, try checking the form and elements are not part of a iframe within the Site you are trying to scrape. Work backwords in the site grab the iframe source and put that in your vbscript rather then the one you have.

Best Luck!