Using Internet Explorer Object in VBA

I have been using Shell, AppActivate, and SendKeys in an Excel VBA macro to post form data and download a file in response (did I hear somebody say Ouch?). Needless to say, the macro is inflexible and doesn't handle errors very well. For  example, I post a stock symbol "MSFT" to the URL "", download the response file "QuoteData.dat", and save the file in a local folder. It seems to me that the Internet Explorer Object might be a solution, but I want to hear from the Experts before I make the attempt. First, is it feasible to perform the above task using the Internet Explorer Object in VBA? Second, if it is feasible, what objects, properties and methods would be involved? And third, am I overlooking a better alternative? A code example would be greatly appreciated.

Who is Participating?
GrahamSkanConnect With a Mentor RetiredCommented:
Set a reference to Microsoft Internet Explorer and Microsoft HTML Library. This is some starter code:

Private Sub Command1_Click()
Dim Ie As New InternetExplorer
Dim objDocument As MSHTML.HTMLDocument
Dim t As Date
Dim i As Integer

Ie.Navigate ""
Ie.Visible = True

'QnD Timer
t = DateAdd("s", 3, Now)
Do Until Now > t

Set objDocument = Ie.Document

Loop Until objDocument.ReadyState = "complete"
Ie.Document.All.Item("ticker").Value = "MSFT"
'routine to find button
'For i = 0 To Ie.Document.All.length - 1
    'If Ie.Document.All.Item(i).tagName = "INPUT" Then
        'If Ie.Document.All.Item(i).Type = "submit" Then
            'Debug.Print i
        'End If
    'End If
'Next i
End Sub

mdmatAuthor Commented:

Thanks for the starter code and the pointer to the object libraries. I will be working with what you have provided and will probably post more questions when I have things in better focus.

All Courses

From novice to tech pro — start learning today.