Need Macro help

WildFire

New Member
Joined
Jun 24, 2008
Messages
3
I'm using the below macro. Does the following
1. Login to yahoo
2. refresh the sheet with url page through web query
First part of loggin in works, however 2nd part doesn't work. I assumed that because i have already logged in it should be able to refresh on the next page but it basically just imports the login page. Some how it doesn't remember what it did few steps back. Any suggestions?

Option Explicit
Public Enum IE_READYSTATE
Uninitialised = 0
Loading = 1
Loaded = 2
Interactive = 3
complete = 4
End Enum
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/23/2008 by
'

'
Const cURL = "http://in.groups.yahoo.com/group/bse-nse2005/files/00-STOCKS%20DATA%20FILES/06%20-%20June%202008"
Const cUserID = "XXXX"
Const cPwd = "YYYY"
Dim ie As Object
Dim doc As HTMLDocument
Dim PageForm As HTMLFormElement
Dim UserIdBox As HTMLInputElement
Dim PasswordBox As HTMLInputElement
Dim FormButton As HTMLInputButtonElement
Dim Elem As IHTMLElement

Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = True
ie.navigate cURL
Do While ie.busy Or Not ie.readyState = IE_READYSTATE.complete: DoEvents: Loop

Set doc = ie.document
Debug.Print "Login page: " & ie.LocationURL
For Each Elem In doc.all
Next
Set PageForm = doc.forms(0)
Set UserIdBox = PageForm.elements("UserName")
UserIdBox.Value = cUserID
Set PasswordBox = PageForm.elements("passwd")
PasswordBox.Value = cPwd
PageForm.submit

With Selection.QueryTable
.Connection = _
"URL;http://in.groups.yahoo.com/group/bse-nse2005/files/00-STOCKS%20DATA%20FILES/06%20-%20June%202008"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,214,835
Messages
6,121,880
Members
449,057
Latest member
Moo4247

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