Advertisement

10.23.2007 at 08:36AM PDT, ID: 22912137
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Controlling Internet Explorer from VBA

Asked by PropertyTaxAnalysts in VB Controls, Internet Explorer Web Browser

Tags: , ,

In my VBA Excel application, I need to use Internet Explorer to obtain some required data. From my VBA program, I also need to be able to set values in the Internet Explorer within several textboxes, select a row in a listbox, and Click on a button all within Internet Explorer.

1. I activated the Internet Explorer using the following code:
      (Credit for this goes to leonstryker)

'=============================================================
Dim IE
Dim objShell

    Set IE = CreateObject("InternetExplorer.Application")
    Set objShell = CreateObject("WScript.Shell")
    With IE
        .Left = 20
        .Top = 20
        .Height = 540
        .Width = 950
        .MenuBar = 0
        .Toolbar = 1
        .StatusBar = 0
        .navigate "http://www.google.com"
        .Visible = True
    End With

    'wait until IE has finished loading itself.
    Do While IE.busy
        DoEvents
    Loop
   
    ' The Internet Explorer is now hopefully ready to accept commands/values or clicks.
    Stop
'==============================================================================

Since I do not know the names of All of the controls in all cases, I put together the following code to find all of the controls on a dummy form I created. It works fine on this dummy form, but what I really want is to be able to find all of the controls within the Internet Explorer. How do I make it look at the Internet Explorer Form rather than my dummy form?

'==============================================================================
Private Sub FindControls()
Dim Top As Integer
Dim Left As Integer
Dim Count As Integer
Dim Name As String
Dim Value As String
Dim temp As String
Dim Caption As String
Dim Enabled As Boolean
Dim Visible As Boolean
Dim FormControl As Control
   
    ' Find all of the controls on a VBA form. See VBA Help on "Controls Collection (Forms)"
    Count = Controls.Count            ' Total number of controls on Form
    For Each FormControl In Controls
        Name = FormControl.Name            ' get the name. ie. btn..., txt..., lst... etc.
        Top = FormControl.Top            ' Get its Top Location
        Left = FormControl.Left            ' get its Left location
        temp = Mid(Name, 1, 3)            ' Get first 3 characters of control name
      ' The 4 controls below don't have values.
        If temp = "frm" Or _
            temp = "lbl" Or _
            temp = "lst" Or _
            temp = "Img" Then
            Else
            Value = FormControl.Value      ' Get current value in the control
        End If
        Visible = FormControl.Visible      ' T/F is it visible
        Enabled = FormControl.Enabled      ' T/F is it enabled
    Next

End Sub
'====================================================================================

At this point I need to be able to place a text string in one or more textboxes, click on a row in a listbox and then programatically initiate an click_Event on a button.  This has to be done FROM within my VBA code TO the controls within the Internet Explorer.

Is anyone aware of any good books or articles that address how to manipulate Internet Explorer from witin a VBA program? So far I've had only marginal luck searching for information on this topic.

John

Start Free Trial
[+][-]10.23.2007 at 11:06AM PDT, ID: 20133014

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Controls, Internet Explorer Web Browser
Tags: vba, internet, explorer
Sign Up Now!
Solution Provided By: Cbrine
Participating Experts: 1
Solution Grade: B
 
 
[+][-]10.23.2007 at 12:20PM PDT, ID: 20133679

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.23.2007 at 12:59PM PDT, ID: 20134058

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.24.2007 at 11:13AM PDT, ID: 20141465

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628