Using Web Queries
Web Queries were introduced in Excel 97 and have been enhanced in each subsequent version of Excel.
They enable you to retrieve a single table of information from a web page, with options to automatically
refresh the data each time the workbook is opened, or at frequent intervals.
One of the problems with Web Queries is that Excel uses the thousands and decimal separators specified
in the Windows Regional Settings when attempting to recognize numbers in the page. If the exchange
rate web page were retrieved in many European countries, the period would be treated as a thousands
separator, not a decimal separator, resulting in exchange rates that are many times too large. In Excel
2002, Microsoft added three properties to the Application object to temporarily override the settings
used when recognizing numbers:
❑ Application.DecimalSeparator—The character to use for the decimal separator
❑ Application.ThousandsSeparator—The same for the thousands separator
❑ Application.UseSystemSeparators—Whether to use the Windows separators or Excel’s
Using these properties, you can set Excel’s separators to match those on the web page, perform the
query, and then set them back again. Web Queries could not be used reliably in versions prior to Excel
2002 in countries that used non-U.S. decimal and thousands separators. If you want to use the Web
Query’s automatic refreshing options, you have to set these separators in the BeforeRefresh event, and
set them back in the AfterRefresh event. This requires advanced VBA techniques, using class modules
to trap events, as discussed in Chapter 16.