S
Shetty
I have certain urls which gives current stock price for that perticuler
stock. I created web query to get those results from web to excel
sheet. Althougt the url is currect and works when pasted on browsers
url box, it fails in the vba code. The error is run time error 1004.
The address of the site is not valid. Check the address and try again.
VBA code fails on line .Refresh BackgroundQuery:=False as indicated
below.
Please note that if I run individual web querry with the same hardcoded
url, it works.
Request some light on this.
Regards,
My code as below.
Sub GET_PRICE_ALL()
R = 1
Sheets("MYLINKS").Select
Sheets("MYLINKS").Range("A" & R).Activate
Do Until IsEmpty(ActiveCell)
MYURL = ActiveCell.Value
GET_PRICE (MYURL)
Sheets("MYLINKS").Activate
ActiveCell.Offset(1, 0).Select
R = R + 1
Loop
End Sub
Sub GET_PRICE(MYURL As String)
Sheets("RESULT").Select
Sheets("RESULT").Range("A" & R + 5).Activate
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;MYURL" _
, Destination:=Sheets("RESULT").Range("A" & R + 5))
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "10"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False <<===here vba code fails.
End With
End Sub
stock. I created web query to get those results from web to excel
sheet. Althougt the url is currect and works when pasted on browsers
url box, it fails in the vba code. The error is run time error 1004.
The address of the site is not valid. Check the address and try again.
VBA code fails on line .Refresh BackgroundQuery:=False as indicated
below.
Please note that if I run individual web querry with the same hardcoded
url, it works.
Request some light on this.
Regards,
My code as below.
Sub GET_PRICE_ALL()
R = 1
Sheets("MYLINKS").Select
Sheets("MYLINKS").Range("A" & R).Activate
Do Until IsEmpty(ActiveCell)
MYURL = ActiveCell.Value
GET_PRICE (MYURL)
Sheets("MYLINKS").Activate
ActiveCell.Offset(1, 0).Select
R = R + 1
Loop
End Sub
Sub GET_PRICE(MYURL As String)
Sheets("RESULT").Select
Sheets("RESULT").Range("A" & R + 5).Activate
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;MYURL" _
, Destination:=Sheets("RESULT").Range("A" & R + 5))
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "10"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False <<===here vba code fails.
End With
End Sub