[RESOLVED] [Excel 2010] Web quries and login details
Hi,
I am looking into downloading stock information from a website (netwealth.com.au) that requires login details to get the information which I then would like to import into excel to be manipulated.
I have done some digging and have found a number of examples but I cant get any of them to work. I can see that this could be quite a difficult ask but any help is greatly appreciated!!!
I have tried using the inbuilt web data function and tried ticking "remember user name" etc. but no luck, so now i'm looking to VBA to help solve this problem.
Thanks in advance,
Ash. :confused:
Re: [Excel 2010] Web quries and login details
show the code variations, you have tried
also the link to the web page, if it is available
Re: [Excel 2010] Web quries and login details
Well when I attempt to got to the page that I want to get the info from it will redirect me to a login page so below are both the login page and the desired page (The first address listed below)
https://www.sharetrading.netwealth.c...?stockCode=MOC
https://www.sharetrading.netwealth.c...nRequired.aspx
Eventually the code will lookup a stock code in a cell that will then be placed into the address (where MOC is) and then download the data for that company... but at this stage all I am trying to figure out is to actually login to the site via VBA.
This is the code that I think is the most relevant (found here: http://www.vbforums.com/showthread.p...ght=login+form)
Code:
Sub Test()
Dim MyPost As String
Const MyUrl As String = "https://www.sharetrading.netwealth.com.au/LoginRequired.aspx"
Const PostUser As String = "ctl00$LoginControl1$txtLogin=Username" 'Change user name here
Const PostPassword As String = "ctl00$LoginControl1$txtPassword=Password" 'Change password here
MyPost = PostUser & PostPassword
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & MyUrl, Destination:=Cells(1, 1))
.PostText = MyPost
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
End Sub
I have attempted to modify it to the login address and page source but have had no luck so far.
Thanks for the help,
Ash.
Re: [Excel 2010] Web quries and login details
i have not tried using a query table but have posted a few examples using an instance of internet explorer, to populate a range from web tables after logging in see the thread below
http://www.vbforums.com/showthread.p...ghlight=iframe also i posted another example recently (about 2 weeks ago), in another thread, also in this forum
Re: [Excel 2010] Web quries and login details