Home > Forum Home > Automating Data Analysis Tasks > Automating a web query login to download data > Two responses Share

Two responses

Excel Help for Two Responses in Automating Data Analysis Tasks


Forum TopicLogin

Two Responses

Rate this:
(3/5 from 1 vote)
OopsFor Nick1234:

Try to use the VBA code at the beginning of this thread to login to the web site that you need the content for in Excel.

For vzny254:

On further investigation I think that Login.aspx is the correct target page and the other page is simply a redirect on the login event.

I think that the issue is that it is a .NET page which requires a valid session variable (you will see this in the HTML source). Therefore you need to first get the session variable from the login page and send it back when you log in.  It is possible to do this using the XML object in VBA.  This is a bit tricky as it will return the HTML source of the page and then you will then need to get the right attribute value to extract the session variable from that.  To use the XML object the code will resemble as follows:

VBA Code:
Sub Read_XML()
Dim xmlDom As MSXML2.DOMDocument
Dim i As Long, j As Long
' Add a reference to Microsoft XML, v6.0
Set xmlDom = New MSXML2.DOMDocument
xmlDom.Load "[ the URL here ]"

For i = 0 To xmlDom.DocumentElement.ChildNodes.Length - 1

Debug.Print "Name Pairs to be printed"
For j = 0 To xmlDom.DocumentElement.ChildNodes.Item(i).ChildNodes.Length
- 1
' Print the name of the column and then the value for the column
Debug.Print
xmlDom.DocumentElement.ChildNodes.Item(i).ChildNodes.Item(j).nodeName, " = ",
xmlDom.DocumentElement.ChildNodes.Item(i).ChildNodes.Item(j).nodeTypedValue

' You will need an If statement here to find the correct tag and then perform the string manipulation
' to get the value from the attribute
Next j

Next i

Set xmlDom = Nothing
End Sub
 Excel Business Forums Administrator
 Posted by on
 
View Full Post

Find relevant Excel templates and add-ins for Two responses in the