Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help pulling data from web page

I wanted some code to log onto my 401k website and extract the values
from various funds in my account. I have been able to combine code
from the following posts to accomplish what I wanted:

http://groups.google.com/group/micro...1e94cde558c098

http://groups.google.com/group/micro...f958f9930907cd

Many thanks to those who contributed. Here is the code that I was able
to put together to accomplish what I wanted (to shorten, I've only
include 1 fund as an example):

Private Const myFund1 As String = "Name of my first fund"

Sub loginLM401k()

' Prepare to open the web page
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = False
.Navigate "https://my401ksite.com"

' Loop until the page is fully loaded
Do Until Not .Busy
DoEvents
Loop

' Make the desired selections on the web page and click the submit
button
Set ipf = ie.Document.all.Item("USERID")
ipf.Value = "myUserID"
Set ipf = ie.Document.all.Item("PIN")
ipf.Value = "1234"
Set ipf = ie.Document.all.Item("but_login")
ipf.Click

' Loop until the page is fully loaded
Do Until Not .Busy
DoEvents
Loop

' Get page source
s = ie.Document.body.innertext

' Logout, loop until the page is fully loaded, and close ie
Set lo = ie.Document.all.Item("glob_logout")
lo.Click
Do Until Not .Busy
DoEvents
Loop
ie.Quit
End With

' Paste the data into active cell

'/ get Investment Co of America Data
nStart = InStr(1, s, myFund1, vbTextCompare)
If nStart Then
nStart = nStart + Len(myFund1)
nEnd = InStr(nStart, s, vbCrLf)
'Debug.Print myFund1 & ": " & Mid$(s, nStart, nEnd -
nStart)
' put the same thing in the active cell
ActiveCell.Value = myFund1 & ": " & Mid$(s, nStart, nEnd -
nStart)
' move to an empty cell to put the next piece of data into
ActiveCell.Offset(1, 0).Activate
End If

' Close the internet explorer application and do cleanup
Set ie = Nothing
Set ipf = Nothing
Set lo = Nothing

End Sub

Now, instead of defining the name of the funds in the code, I would
like to look them up in a worksheet. Actually, I would like to lookup
all the funds listed in, say, column A, then loop through to get data
for each one. I don't have a clue how to do this. Can anyone help?

Also, is there anything in the code that is unecessary or inefficient?
I'm a novice.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help pulling data from web page

Can anyone help with this?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tying to extract all data from a pivot pulling from external data Ted Urban Excel Discussion (Misc queries) 3 September 14th 07 10:50 AM
PULLING A VALUE FROM A CELL ON ANOTHER PAGE/WORKSHEET ng66 Excel Discussion (Misc queries) 6 January 26th 07 02:03 AM
Pulling selected data from a detail page to a summary Redline Excel Discussion (Misc queries) 2 January 16th 06 04:05 PM
Saving worksheet as CSV after pulling data from an external data source Richard Edwards[_3_] Excel Programming 4 February 25th 05 09:08 PM
Pulling and Pushing web page data Bruce McPherson Excel Programming 1 August 27th 03 09:07 AM


All times are GMT +1. The time now is 01:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"