Solved

Using Internet Explorer Object in VBA

Posted on 2004-10-08
2
2,459 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now