Hello,
I am having problems getting to work a web query in a VBA macro. The goal is simply to get a value retrieved from a web query into an excel cell.
The below code works well with standard html pages (like replacing the url with www.google.com). However, the page I want to retreive (a query at geonames.org that retreives an altitude value for given lattitude/longitude values) does not contain any HTML headers, but just a number in plain text. In this case the below query does not returns anything. I tried different formating options for the query but up to nownothing works. Any idea how to solve this ? Thanks in advance !
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://ws.geonames.org/srtm3?lat=50.01&lng=10.2" _
, Destination:=Range("G1"))
.Name = "testme"
.RowNumbers = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.SaveData = True
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=True
End With
Bookmarks