Private objXL As Object
Sub s()
Set objXL = GetObject("D:\Documents\Excel files\CBrates.xls")
L = objXL.ActiveSheet.Cells(1, 9)
On Error GoTo errorhandler
M = Month(L)
D = Day(L)
Y = Year(L)
If M < 10 Then MS = "0" & M Else MS = M
If D < 10 Then D = "0" & D
With objXL.ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.cbr.ru/currency_base/D_print.asp?date_req=" & D & "/" & MS & "/" & Y & """", _
Destination:=Range("A1"))
.Name = "CBRrates"
.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 = "3"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
Exit Sub
errorhandler:
MsgBox ("Error: probably internet connection can not be established." & " Displayed rates for " & L)
Set objXL = Nothing
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 43