Excel - Access Web Page

J

judith

I regularly access some web pages - I want to do so via VBA.

I must access them via a log-in page - I can then access all other
pages on the site.

I have opened the initial web page in my browser and logged in. I
then open second page from within VBA but instead of going to called
page it goes to log-in page.

How can I log-in via VBA - keep web session active (if that is correct
terminology) and then access other pages?
 
G

George Z

Hi Judith,

Below is a function I used once to show that VBA could do a HTTP post to a
site.

You will need to customise it to login to your website though (included a
test to show how it is called):

Function searchPost(ByVal strNumber As String, ByVal strName As String, _
ByVal strSuburb As String, ByVal strState As String)
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
On Error GoTo errHandler
With ie
.navigate "http://www.whereis.com/whereis/map.do"
Do While .busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
With .document.Forms(1)
.addressStreetNo1.Value = strNumber
.addressStreetName1.Value = strName
.addressSuburb1.Value = strSuburb
.addressState1.Value = strState
.submit
End With

Do While .busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
.Visible = True

End With
Exit Function
errHandler:
ie.Quit: Set ie = Nothing
End Function

Sub testSearchAUPost()
searchPost "101", "Collins Street", "Melbourne", "Victoria"
End Sub

Note that the HTTP Document form objects are hardcoded, in your case, you
would locate the username/password form fields to place into the script.

Hope this helps
 
J

judith

Hi Judith,

Below is a function I used once to show that VBA could do a HTTP post to a
site.


<snip>

That's great - just the start I was looking for - many thanks
 

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