Solved

Using Internet Explorer Object in VBA

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

914 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

13 Experts available now in Live!

Get 1:1 Help Now