Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I often import stock quotes using the QueryDef method without any problems. But for some reasons I'm not able to import certain stocks quotes. Sometimes the macro works, sometimes not (Error 1004) and I don't know why. I created the following example: Sub ImportData() Dim ws As Worksheet Dim qry As QueryTable Dim n As Name Dim sURL As String sURL = "http://www.swissquote.ch/fcgi-bin/stockfquote?symbols=ALFGR" Set ws = ThisWorkbook.Worksheets(1) 'delete old data ws.Cells.Delete For Each qry In ws.QueryTables qry.Delete Next qry For Each n In ThisWorkbook.Names n.Delete Next n 'import With ws.QueryTables.Add(Connection:="URL;" & sURL, Destination:=ws.Range("$A$1")) .Name = "stockfquote?symbols=ALFGR" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With End Sub Has anybody an idea why this script generates the error 1004? Tom |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Error handling error # 1004 Run-time error | Excel Programming | |||
runtime error '1004' application or object defined error. Please help | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming |