Microsoft Office Tutorials and References
In Depth Information
Try It
10.
Open a With structure for the Add method of your new QueryTable. The connection, URL,
destination sheet, and other information that follows must be specified.
With .QueryTables.Add _
(Connection:=”URL;” &strURL, Destination:=.Range(“A1”))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
11.
Close the With structure of the QueryTable’s Add method:
End With
12.
Close the With structure for the destination worksheet:
End With
13.
Your entire macro will look as follows:
Sub TimeAfterTime()
‘Open a With structure for the destination worksheet.
With Worksheets(“Sheet1”)
‘Declare a String type variable for the website address.
Dim strURL As String
‘Define the website address, from which the information
‘will be imported to your worksheet.
strURL = _
“http://tycho.usno.navy.mil/cgi-bin/timer.pl”
‘For consistency, I prefer to activate the worksheet
‘that will receive the web data.
‘Cell A1 is a convenient cell to situate yourself.
Application.Goto .Range(“A1”), True
‘Clear the cells in the worksheet so you know the data
‘being imported will not be confused with other data
‘you may have imported previously and not yet deleted.
Cells.Clear
‘Open a With structure for the Add method of your new
‘QueryTable. The connection, URL, and destination sheet,
‘and other information that follows, must be specified.
With .QueryTables.Add _
(Connection:=”URL;” &strURL, Destination:=.Range(“A1”))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
Search JabSto ::




Custom Search