Opening Web Pages as Workbooks

The simplest solution is to open the entire web page as if it were a workbook, then scan the sheet for the required information, such the USD/GBP exchange rate:

Sub OpenUSDRatesPage()

Dim oBk As Workbook Dim oRng As Range

'Open the rates pages as a workbook

Set oBk = Workbooks.Open("") 'Find the British Pounds entry

Set oRng = oBk.Worksheets(1).Cells.Find("British Pound") 'Read off the exchange rate

MsgBox "The USD/GBP exchange rate is " & oRng.Offset(0, 1).Value End Sub

The problem with using this approach is that you have to load the entire web page (including graphics, banners, and so on), which may have much more information than you want. The irrelevant data can greatly slow down the speed of data retrieval.

0 0

Post a comment