ID and access currently active web page (in IE6)?

K

ker_01

I googled, but no joy. Using Excel 2003.

I have other code I've used to navigate, open, and parse web pages- but all
from within Excel, it never popped up in IE. However, now I need to parse a
page that I can't open directly from Excel (I have to enter a screen-based
code to go from page to page). So, I'd like to be able to manually navigate
in IE, then run my macro to scrape the key elements from the IE web page and
bring them into my target worksheet range.

Can anyone help me with the syntax to point Excel to the currently active IE
page?

Thank you,
Keith
 
R

ryguy7272

Sounds like you have to login with a username and password. See this sample
code (I got it from this DG a short time ago):

Sub Login()

'This gets rid of the duplicate data
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

HomeURL = "http://www.countrybobsdemo.com/administrator/"

'get web page
IE.Navigate2 HomeURL
Do While IE.readyState <> 4
DoEvents
Loop

Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getelementsbytagname("Form")

Set NameBox = IE.document.getElementById("modlgn_username")
'check if already login
If Not NameBox Is Nothing Then
NameBox.Value = "Ryan"

Set PasswordBox = IE.document.getElementById("modlgn_passwd")
PasswordBox.Value = "ryan123"

Form(0).submit
Do While IE.busy = True
DoEvents
Loop
End If

URL = "index.php?option=com_rsform&task=submissions.manage&formId=2"

'get web page
IE.Navigate2 HomeURL & URL
Do While IE.readyState <> 4
DoEvents
Loop

Do While IE.busy = True
DoEvents
Loop

Set Mytables = IE.document.getelementsbytagname("table")

Set History = Mytables(2)

RowCount = 1
For Each itm In History.Rows
ColCount = 1
For Each Col In itm.Cells
Select Case Col.Children.Length

Case 0, 1, 2
Cells(RowCount, ColCount) = Col.innertext
Case Is >= 3
Cells(RowCount, ColCount) = Col.Children(1).innertext
End Select

ColCount = ColCount + 1
Next Col

RowCount = RowCount + 1
Next itm
End Sub


HTH,
Ryan---
 
R

ron

I googled, but no joy. Using Excel 2003.

I have other code I've used to navigate, open, and parse web pages- but all
from within Excel, it never popped up in IE. However, now I need to parsea
page that I can't open directly from Excel (I have to enter a screen-based
code to go from page to page). So, I'd like to be able to manually navigate
in IE, then run my macro to scrape the key elements from the IE web page and
bring them into my target worksheet range.

Can anyone help me with the syntax to point Excel to the currently activeIE
page?

Thank you,
Keith

Keith...You should be able to accomplish this programmatically using
an input box to manually enter the screen-based code. What url do you
start with and where do you want to wind up?..Ron
 
K

ker_01

The full sequence of events is that I access the target URL, login, make some
selections that forwards me to a second (secure) website; then I go through
about 4 screens to set up various search parameters and get my results. The
website has built-in security that prevents copy/paste of screen contents, so
I need to use Regex against the page source to grab the data I need. In
addition, to go from page to page, I have to enter/type a visual code for
security purposes.

I'm totally fine with the login process, and it is complex enough that I'd
hate to have to try to do it (text entry, combobox selections, etc) via code
and sendkeys. So, I get to the point where I already have an instance of IE6
open (not opened from Excel) and the problem I have is that I don't know how
to get Excel to find the instance of IE6 and capture the page code, since the
process wasn't started in Excel. I'm thinking something like:

Dim MyBrowser as InternetExplorer6.Instance
Set MyBrowser = InternetExplorer.activewindow
Dim currentpage as string
currentpage = MyBrowser.source
'then use regex to parse out the key data

I appreciate any assistance or code snippets!

Thank you,
Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top