Jump to content

My tweak for _IETableWriteToArray


Recommended Posts

I am learning Internet Automation via Autoit. Last week I needed info on all the tables on a page. I wrote this little UDF based on the help file for _IETableGetCollection. But it would crash sometimes. The problem was "empty" tables on the web page. I stole some code from the INCLUDE file and modified it to check for blanks tables. It now works OK for me. I hope this helps someone.

Jim Rumbaugh

Func _IETableReport( $oIE)
    Local $iIndex = 0
    $colTables = _IETableGetCollection($oIE)
    MsgBox(0, "Table Info", "There are " & @extended & " tables on the page")

    for $oTable In $colTables
        ;===== stolen from IE include _IETableWriteToArray, to find errors
        Local $i_cols = 0, $tds, $i_col
        Local $trs = $oTable.rows
        For $tr In $trs
            $tds = $tr.cells
            $i_col = 0
            For $td In $tds
                $i_col = $i_col + $td.colSpan
            Next
            If $i_col > $i_cols Then $i_cols = $i_col
        Next
        Local $i_rows = $trs.length
        If $i_cols = 0 Or $i_cols = 0 Then
            MsgBox(1, "Failure to make good array from table", "Column count=" & $i_cols & "  Row count =" & $i_cols )
                ;======== end of , find array problems
        Else
            $aTableData = _IETableWriteToArray($oTable)
            _ArrayDisplay($aTableData, "Table #" & $iIndex)
            $iIndex += 1
        EndIf
    next
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...