VBA IE automation

wid2001

New Member
Joined
Jan 30, 2014
Messages
28
I am trying to scrape a table from the website fltplan.com. I have been able to login utilizing VBA. I run into issues when trying to scrape the active flight plan table. The code I am utilizing to login is:

Code:
Sub GetTable()
   
    Dim ieApp As InternetExplorer
    Dim ieDoc As Object
    Dim ieTable As Object
    Dim clip As DataObject
   
    'create a new instance of ie
    Set ieApp = New InternetExplorer
   
    'you don’t need this, but it’s good for debugging
    ieApp.Visible = True
   
    'assume we’re not logged in and just go directly to the login page
    ieApp.Navigate "http://www.fltplan.com/"
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
           
    Set ieDoc = ieApp.Document
   
    'fill in the login form – View Source from your browser to get the control names
    With ieDoc.forms(0)
        .UserName.Value = "myusername"
        .Password.Value = "mypassword"
        .submit
    End With
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
   
    'now that we’re in, go to the page we want
    ieApp.Navigate "https://www.fltplan.com/AwRegUserCk.exe?a=1"
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
   
    'get the table based on the table’s id
    Set ieDoc = ieApp.Document
    Set ieTable = ieDoc.all.Item("fpc2")
   
    'copy the tables html to the clipboard and paste to the sheet
    If Not ieTable Is Nothing Then
        Set clip = New DataObject
        clip.SetText "" & ieTable.outerHTML & ""
        clip.PutInClipboard
        Sheet10.Select
        Sheet10.Range("C3").Select
        Sheet10.PasteSpecial "Unicode Text"
    End If

I was unable to utilize the above code in its entirety but it worked great for the login. After the login is where I ran into trouble.
I am fairly new with IE automation but I think that if I was able to navigate the web page utilizing the buttons to the place where my table is I would have better luck. I also have been unable to determine a table ID for the data that I want. but I need to successfully navigate there first. Two buttons need pressed to get to my data.

This is the code when I select inspect element for the first button:


<input class="TitleButton" value="Flight Planning" *******="CheckB1(this)" type="button">

And this is for the second button:


<input class="FPButtons" value="Flight Listing • " type="submit">


Any help would be appreciated. Thanks
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I still haven't found a good answer to this. Anyone have any ideas or point me to a good source. I have searched the forums but haven't been able to find a solution.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top