Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Excel web queries using parameters

I am trying to setup a MS Excel web query based on the following URL:

http://finance.yahoo.com/currency/co...submit=Convert

This is the Yahoo currency converter web page

When I introduce a parameter for amount this works OK as follows:

http://finance.yahoo.com/currency/convert?amt=["amount"]&from=USD&to=JPY&submit=Convert

However when I introduce parameters for the from and the to currency this
does not work as follows:

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Can anyone tell me why? What am I doing wrong? Is there another way around
this?

The only thing I can possible think of is that the from and to currency on
the web site are drop down lists of values where the amount field is not.

Many thanks in anticipation

RobC
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Excel web queries using parameters

Try this macro after you have imported using named ranges for amount, from &
to

Sub ConvertCurrency()
With Selection.QueryTable
.Connection = _
"URL;http://finance.yahoo.com/currency/convert?amt=" _
& [amount] & "&from=" & [from] & "&to=" & [to] & "&submit=Convert"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8,10,11,13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
I am trying to setup a MS Excel web query based on the following URL:

http://finance.yahoo.com/currency/co...submit=Convert

This is the Yahoo currency converter web page

When I introduce a parameter for amount this works OK as follows:

http://finance.yahoo.com/currency/convert?amt=["amount"]&from=USD&to=JPY&submit=Convert

However when I introduce parameters for the from and the to currency this
does not work as follows:

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Can anyone tell me why? What am I doing wrong? Is there another way around
this?

The only thing I can possible think of is that the from and to currency on
the web site are drop down lists of values where the amount field is not.

Many thanks in anticipation

RobC



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Excel web queries using parameters

Hi Don

Many thanks for your reply

The problem is that I cannot import the named ranges for "from" & "to" when
I try I get a message on the web site in the Edit Web Query "Bad request" and
no data is imported into Excel

This is what I am using in the Address in Edit Web Query window then click
Inport

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Regards

RobC

-----------------------------

"Don Guillett" wrote:

Try this macro after you have imported using named ranges for amount, from &
to

Sub ConvertCurrency()
With Selection.QueryTable
.Connection = _
"URL;http://finance.yahoo.com/currency/convert?amt=" _
& [amount] & "&from=" & [from] & "&to=" & [to] & "&submit=Convert"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8,10,11,13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
I am trying to setup a MS Excel web query based on the following URL:

http://finance.yahoo.com/currency/co...submit=Convert

This is the Yahoo currency converter web page

When I introduce a parameter for amount this works OK as follows:

http://finance.yahoo.com/currency/convert?amt=["amount"]&from=USD&to=JPY&submit=Convert

However when I introduce parameters for the from and the to currency this
does not work as follows:

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Can anyone tell me why? What am I doing wrong? Is there another way around
this?

The only thing I can possible think of is that the from and to currency on
the web site are drop down lists of values where the amount field is not.

Many thanks in anticipation

RobC




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Excel web queries using parameters


Send me your workbook and I will take a look.
--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
Hi Don

Many thanks for your reply

The problem is that I cannot import the named ranges for "from" & "to"
when
I try I get a message on the web site in the Edit Web Query "Bad request"
and
no data is imported into Excel

This is what I am using in the Address in Edit Web Query window then click
Inport

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Regards

RobC

-----------------------------

"Don Guillett" wrote:

Try this macro after you have imported using named ranges for amount,
from &
to

Sub ConvertCurrency()
With Selection.QueryTable
.Connection = _
"URL;http://finance.yahoo.com/currency/convert?amt=" _
& [amount] & "&from=" & [from] & "&to=" & [to] &
"&submit=Convert"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8,10,11,13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
I am trying to setup a MS Excel web query based on the following URL:

http://finance.yahoo.com/currency/co...submit=Convert

This is the Yahoo currency converter web page

When I introduce a parameter for amount this works OK as follows:

http://finance.yahoo.com/currency/convert?amt=["amount"]&from=USD&to=JPY&submit=Convert

However when I introduce parameters for the from and the to currency
this
does not work as follows:

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Can anyone tell me why? What am I doing wrong? Is there another way
around
this?

The only thing I can possible think of is that the from and to currency
on
the web site are drop down lists of values where the amount field is
not.

Many thanks in anticipation

RobC






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Excel web queries using parameters

Don

Many thanks for the tip. I have managed to get around the problem with a
macro as follows:

Dim amount As String
Dim currency_from As String
Dim currency_to As String

amount = 1
currency_from = InputBox("Please enter currency from")
currency_to = InputBox("Please enter currency to")

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/currency/convert?amt=" & amount &
"&from=" & currency_from & "&to=" & currency_to & "&submit=Convert" _
, Destination:=Range("A1"))
.Name = "convert?amt=1=USD&to=JPY&submit=Convert_16"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Note the syntax in the URL line.

It seems to work OK. I am new to this VBA stuff any improvements greatfully
received. What is the .New line about?

Once again many thanks for your time it is very much appreciated.

--
Rob Cherry


"Don Guillett" wrote:


Send me your workbook and I will take a look.
--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
Hi Don

Many thanks for your reply

The problem is that I cannot import the named ranges for "from" & "to"
when
I try I get a message on the web site in the Edit Web Query "Bad request"
and
no data is imported into Excel

This is what I am using in the Address in Edit Web Query window then click
Inport

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Regards

RobC

-----------------------------

"Don Guillett" wrote:

Try this macro after you have imported using named ranges for amount,
from &
to

Sub ConvertCurrency()
With Selection.QueryTable
.Connection = _
"URL;http://finance.yahoo.com/currency/convert?amt=" _
& [amount] & "&from=" & [from] & "&to=" & [to] &
"&submit=Convert"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8,10,11,13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
I am trying to setup a MS Excel web query based on the following URL:

http://finance.yahoo.com/currency/co...submit=Convert

This is the Yahoo currency converter web page

When I introduce a parameter for amount this works OK as follows:

http://finance.yahoo.com/currency/convert?amt=["amount"]&from=USD&to=JPY&submit=Convert

However when I introduce parameters for the from and the to currency
this
does not work as follows:

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Can anyone tell me why? What am I doing wrong? Is there another way
around
this?

The only thing I can possible think of is that the from and to currency
on
the web site are drop down lists of values where the amount field is
not.

Many thanks in anticipation

RobC








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Excel web queries using parameters

The way you are doing it will ultimately create a lot of bloat by adding
queries each time without removing. So, I suggest you use something like
this after the query is created. I just tested. Again, named ranges or you
can use the input box if desired.

Sub ConvertCurrency()
With Sheets("Sheet1").QueryTables(1)
.Connection = _
"URL;http://finance.yahoo.com/currency/convert?amt=" _
& [amount] & "&from=" & [from] & "&to=" & [to] & "&submit=Convert"
.WebTables = "13"
.Refresh BackgroundQuery:=False
End With
End Sub


--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
Don

Many thanks for the tip. I have managed to get around the problem with a
macro as follows:

Dim amount As String
Dim currency_from As String
Dim currency_to As String

amount = 1
currency_from = InputBox("Please enter currency from")
currency_to = InputBox("Please enter currency to")

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/currency/convert?amt=" & amount &
"&from=" & currency_from & "&to=" & currency_to & "&submit=Convert" _
, Destination:=Range("A1"))
.Name = "convert?amt=1=USD&to=JPY&submit=Convert_16"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Note the syntax in the URL line.

It seems to work OK. I am new to this VBA stuff any improvements
greatfully
received. What is the .New line about?

Once again many thanks for your time it is very much appreciated.

--
Rob Cherry


"Don Guillett" wrote:


Send me your workbook and I will take a look.
--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
Hi Don

Many thanks for your reply

The problem is that I cannot import the named ranges for "from" & "to"
when
I try I get a message on the web site in the Edit Web Query "Bad
request"
and
no data is imported into Excel

This is what I am using in the Address in Edit Web Query window then
click
Inport

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Regards

RobC

-----------------------------

"Don Guillett" wrote:

Try this macro after you have imported using named ranges for amount,
from &
to

Sub ConvertCurrency()
With Selection.QueryTable
.Connection = _
"URL;http://finance.yahoo.com/currency/convert?amt=" _
& [amount] & "&from=" & [from] & "&to=" & [to] &
"&submit=Convert"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8,10,11,13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

--
Don Guillett
SalesAid Software

"Rob Cherry" wrote in message
...
I am trying to setup a MS Excel web query based on the following URL:

http://finance.yahoo.com/currency/co...submit=Convert

This is the Yahoo currency converter web page

When I introduce a parameter for amount this works OK as follows:

http://finance.yahoo.com/currency/convert?amt=["amount"]&from=USD&to=JPY&submit=Convert

However when I introduce parameters for the from and the to currency
this
does not work as follows:

http://finance.yahoo.com/currency/convert?amt=1&from=["from"]&to=["to"]&submit=Convert

Can anyone tell me why? What am I doing wrong? Is there another way
around
this?

The only thing I can possible think of is that the from and to
currency
on
the web site are drop down lists of values where the amount field is
not.

Many thanks in anticipation

RobC








  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 122
Default Excel web queries using parameters

If you're interested, I have a free open-source add-in that can grab
the data for you. The add-in, documentation on its functions, and
sample templates can be found in the files area of this Yahoo group:

http://finance.groups.yahoo.com/group/smf_addin/

I think the best way to get the data you want would be to use the
Yahoo current quotes interface. For example, with my add-in, I could
use this formula to get the last price for USD into JPY:

=RCHGetYahooQuotes("USDJPY=X","l1")

....or, if you wanted to get last traded price, date of the last trade,
time of the last trade, bid and ask prices, you could array-enter this
version of that formula over a 1-row by 5-column range:

=RCHGetYahooQuotes("USDJPY=X","l1d1t1ba")

You could get multiple ticker symbols as well -- this could be array-
entered over 2 columns and 6 rows:

=RCHGetYahooQuotes("USDJPY=X,USDGBP=X","sl1d1t1ba" )

Also, there is a template in the files area that can get historical
data from this web site:

http://fx.sauder.ubc.ca/

On Mar 17, 11:38 am, Rob Cherry
wrote:
I am trying to setup a MS Excel web query based on... the following URL:
...the Yahoo currency converter web page


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parameters in SQL queries using "contains" or "like" StuartAberdein Excel Discussion (Misc queries) 0 June 22nd 06 11:18 AM
Use of Parameters in Excel sarjak Excel Discussion (Misc queries) 7 February 1st 06 06:42 PM
Parameters in Excel Brandon Williams Excel Discussion (Misc queries) 3 October 18th 05 01:56 PM
Excel Queries with subqueries and parameters theday_99@yahoo Excel Discussion (Misc queries) 0 September 28th 05 01:24 PM
Parameters are not allowed in queries that can't be displayed grap Flora Tzeng Excel Discussion (Misc queries) 1 March 15th 05 10:34 AM


All times are GMT +1. The time now is 04:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"