I recently performed a webquery from vba. The coding went somehow like this:
Dim Wkb as WorkBook
Dim QT as QueryTable
Set Wkb = Workbooks.Add
With Wkb.Worksheets(1)
Set QT = .QueryTables.Add(Connection:= "URL; Destination:= .Range("A1"
)
End With
With QT
.WebSelectionType = xlSpecifiedTables
.WebTables = "2"
...
End With
QT.Refresh BackgroundQuery:= False
A reference to MS EXCEL 10 was set in the project.
The program performed up to my expectations: it did open an internet connection, asked for a password to get through and downloaded the requested table in the worksheet.
However, the connection remained open after the download. Even after the program ended! Obvious question: How can I (or the program's user if he/she desires to do so) close that connection?
The MaintainConnection property seems to work only for OLE DB databases, not for internet connections.
I couldn't find any other method or property within excel'S rich vocabulary to do so. Is the blame on me?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
Dim Wkb as WorkBook
Dim QT as QueryTable
Set Wkb = Workbooks.Add
With Wkb.Worksheets(1)
Set QT = .QueryTables.Add(Connection:= "URL; Destination:= .Range("A1"
End With
With QT
.WebSelectionType = xlSpecifiedTables
.WebTables = "2"
...
End With
QT.Refresh BackgroundQuery:= False
A reference to MS EXCEL 10 was set in the project.
The program performed up to my expectations: it did open an internet connection, asked for a password to get through and downloaded the requested table in the worksheet.
However, the connection remained open after the download. Even after the program ended! Obvious question: How can I (or the program's user if he/she desires to do so) close that connection?
The MaintainConnection property seems to work only for OLE DB databases, not for internet connections.
I couldn't find any other method or property within excel'S rich vocabulary to do so. Is the blame on me?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]