Results 1 to 3 of 3

Error in Macro: (Refresh BackgroundQuery:=False)

Threaded View

abehnamian Error in Macro: (Refresh... 10-26-2008, 11:23 AM
Leith Ross Hello abehnamian, Welocme... 10-26-2008, 12:38 PM
abehnamian Thanks Lieth 10-26-2008, 12:45 PM
  1. #1
    Registered User
    Join Date
    10-26-2008
    Location
    Edmonton
    Posts
    2

    Error in Macro: (Refresh BackgroundQuery:=False)

    Hi there,
    There is a problem in my Macro code. I really appreciate if you could advise me in this regard. I am trying to collect some information from MSN Money for some companies listed in stock market. I have some symbols (companies' name in Sheet1) and this macro takes these symbols one by one and through Web Query it imports one table of information for each symbol. When I run this code for the first time on a computer, it works. But when I try to run it more times, I will get "run time error 1004" for this line:

    Refresh BackgroundQuery:=False

    Could you help me. Thanks in advance
    This is my code: (file is attached)

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    size_table = 30
    '
    
    stock_symbol = "ibm"
    
    For i = 0 To 200
        
        stock_symbol = Worksheets("Sheet1").Cells(2 + i, 2)
        bb = "A" + CStr(i * size_table + 1) + ":A" + CStr((i + 1) * size_table + 1)
        Worksheets("Sheet4").Range(bb) = stock_symbol
    
        With Worksheets("Sheet4").QueryTables.Add(Connection:= _
            "URL;http://moneycentral.msn.com/ownership?Holding=Institutional+Ownership&Symbol=" + stock_symbol _
            , Destination:=Worksheets("Sheet4").Range("$A$1").Offset(i * size_table, 1))
             .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertEntireRows
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "4"
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
            
        End With
        Worksheets("Sheet4").QueryTables.Item(1).Delete
        Next i
     '       Set a = ActiveSheet.QueryTable
    End Sub
    Attached Files Attached Files
    Last edited by VBA Noob; 10-26-2008 at 11:59 AM. Reason: Mod added code tags as per forum rules. Do not change again

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1