Question

We have a web query on an Excel worksheet that goes to MoneyFacts (Moneyfacts website) for the latest Bond & ISA savings rates.

The rates page requires a login by username and password before the rates page is shown (as it's a subscription site).

Through trial and error and looking at the soruce of the login page, I was able to determin that I need to add these symbols to the connection:

  • User Name: ctl00$body$txtUsername
  • Password: ctl00$body$txtPassword

so I changed thec onnection property of the datatable as below:

sheets("ISA 3Yr").range("A12").QueryTable.Connection="URL;http://analyser.moneyfacts.co.uk/savings/forms/frmDashboard.aspx?symbol=[""body_txtUsername""]”&symbol=[""body_txtPassword""]”&did=37&module=2&tocfilter=15&view=2&rerun=92680f6c-9fcc-4585-9b2a-aaf9b281cf88"

Now, when we click refresh All on the ribbon the first time, the dialogs are shown so we can enter the username and password. Each time we chose entered the data and the web query refreshed.

But the next time, without asking for the login, it fails.

How can we pass parameters to web queries properly ?

Was it helpful?

Solution

Either you pass parameters in the query string portion of the web url, so in your example you have did=37&module=2&tocfilter=15&view=2& which is a series of key value pairs which gives

did=37   
module=2
tocfilter=15
view=2

or they are posted in the HTTP header. You'll need an HTTP sniffer tool to investigate further. I used Fiddler at http://www.telerik.com/fiddler and it is quite good.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top