Recorded Excel Macro not working

S

Subrat

Hi,
I recorded an excel macro in excel 2007 which is basically a web query. It
runs fine while i record it (Data->Import External Data->New Web Query),but
doesnt work when i run the recorded macro ( gives Run-time Error '1004':
Invalid Web Query). I am guessing there is a problem with the URL since if i
replace the URL with any other URL,it is working.
Below is the VBA code which got auto-generated when the macro got recorded.
Sub Stockcharts()
'
' Stockcharts Macro
' Macro recorded 5/16/2010 by subrat
'
'
With ActiveSheet.QueryTables.Add(Connection:= _

"URL;http://stockcharts.com/def/servlet/...0,tc_gt_as0,200,tc]![as1,50,tc_le_as1,200,tc]" _
, Destination:=Range("A1"))
.Name = _

"SC.scan?s=TSA[t.t_eq_s]![as0,20,tv_gt_40000]![as0,50,tc_gt_as0,200,tc]![as1,50,tc_le_as1,200,tc]"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "11"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("C1:K11").Select
Selection.ClearContents
End Sub
Any help would be appreciated.
Thanks
 
P

Paul Robinson

Hi
The URL is split over 2 lines. Is that just because of my mail reader
or is it that way in the macro? As in some of your other lines you
would need a " _" to continue the line. Clutching at straws a bit!
regards
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top