Solved

Using Internet Explorer Object in VBA

Posted on 2004-10-08
2
2,477 Views
Last Modified: 2013-12-26
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 "http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx", 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.

Thanks
0
Comment
Question by:mdmat
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 12270840
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 "http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx"
Ie.Visible = True

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

Set objDocument = Ie.Document

Do
    DoEvents
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
Ie.Document.All.Item(400).Click
End Sub


0
 

Author Comment

by:mdmat
ID: 12274031
GrahamSkan,

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.

MDMAT
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question