Use of Internet Explorer and MSHTML object

Saturday, May 17, 2008

How to use Internet Explorer controls in vb ?
Dim ie As New InternetExplorer
Dim hdoc As mshtml.IHTMLDocument
Dim iHTMLCol As IHTMLElementCollection
Dim iHTMLEle As IHTMLElement

ie.navigate ("about:blank")
ie.Visible = False
Do

Loop Until Not ie.Busy
str = ie.document.body.innerText
If str Like "*cannot be*" Then
msgbox "Check For Internet Connection"
End If

str = ie.document.body.innerText
If str Like "*cannot be*" Then
ValidatePANInformation = "Check For Internet Connection"
Exit Function
End If

Set hdoc = ie.document
Set iHTMLCol = hdoc.getElementsByTagName("input")
Do
For Each iHTMLEle In iHTMLCol
If iHTMLEle.name = "abc" Then
iHTMLEle.innerText = " "
End If

If iHTMLEle.name = "XYZ" Then
iHTMLEle.Click
End If
Next
Loop While SetValue <> True

Do

Loop Until Not ie.Busy

Set iHTMLCol = hdoc.getElementsByTagName("span")
Do

For Each iHTMLEle In iHTMLCol
If iHTMLEle.id = "nameofcontrol" Then
'MsgBox iHTMLEle.innerText
End If
Next
Loop While SetValue <> True
ie.Quit

0 comments

Post a Comment