PDA

View Full Version : verify text of IE



rjndra
11-23-2009, 01:37 AM
How to verify text (text box properties) / page title of IE using excel VBA.

Oorang
11-25-2009, 01:01 PM
Does this help?
Public Sub Example()
'Needed Project References:
' -Microsoft Internet Controls
' C:\Windows\system32\ieframe.dll
' -Microsoft HTML Object Library
' C:\Windows\system32\mshtml.tlb
Dim ie As SHDocVw.InternetExplorer
Dim doc As MSHTML.HTMLDocument
Dim tbx As MSHTML.HTMLInputTextElement
Dim btn As MSHTML.HTMLButtonElement
Set ie = New SHDocVw.InternetExplorer
ie.Visible = True
ie.Navigate "http://www.google.com"
WaitForPageLoad ie
Set doc = ie.Document
Set tbx = doc.getElementsByName("q").Item(, 0)
tbx.Value = "VBA Express"
MsgBox "The textbox now says: " & tbx.Value
Set btn = doc.getElementsByName("btnG").Item(, 0)
btn.Click
WaitForPageLoad ie
End Sub

Private Sub WaitForPageLoad(ByRef ie As SHDocVw.InternetExplorer)
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
End Sub