+ Reply to Thread
Results 1 to 1 of 1

Web Query Error 1004

  1. #1
    Registered User
    Join Date
    01-31-2009
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    66

    Web Query Error 1004

    This doesn't happen all the time which is weird... Basically, all I do is change the stock symbol. In this example its "BP."

    It will work with 50/60 sheets and won't work with others. All of the links have a "?" in it.

    I'll click "Refresh all" and a box will come up with the following:

    Run-time error '1004':

    The file could not be accessed. Try one of the following:

    Make sure:
    the specified folder exists.
    the foloder that contains teh file is not read-only
    the name does not contain: < > ? [ ] or *
    Make sure the file/path name doesn't contain more than 218 characters.

    This is what i'm running:

    Sub GetWebsite()
    '
    ' Macro2 Macro
    '

    '
    Range("A4").Select
    With Selection.QueryTable
    .Connection = "URL;http://www.google.com/finance?q=BP"
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingAll
    .WebTables = """md"""
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    Range("A11").Select
    With Selection.QueryTable
    .Connection = _
    "URL;http://www.reuters.com/finance/stocks/ratios?symbol=BP.n"
    .WebSelectionType = xlAllTables
    .WebFormatting = xlWebFormattingAll
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=72
    Range("A88:A89").Select
    With Selection.QueryTable
    .Connection = _
    "URL;http://www.reuters.com/finance/stocks/estimates?symbol=BP.n"
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingAll
    .WebTables = "1,2,3"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=54
    Range("A129:A130").Select
    With Selection.QueryTable
    .Connection = _
    "URL;http://www.reuters.com/finance/stocks/recommendations?symbol=BP.n"
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingAll
    .WebTables = "1"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    Range("A134").Select
    With Selection.QueryTable
    .Connection = _
    "URL;http://quicktake.morningstar.com/StockNet/GrowthRates10.aspx?Country=USA&Symbol=BP"
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "9,11,13"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=-138
    Range("N11").Select
    With Selection.QueryTable
    .Connection = _
    "URL;http://quicktake.morningstar.com/StockNet/Snapshot.aspx?Country=USA&Symbol=BP"
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "19,20,21"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 10
    Range("R11").Select
    With Selection.QueryTable
    .Connection = _
    "URL;http://quicktake.morningstar.com/StockNet/StockValuation.aspx?Country=USA&Symbol=BP"
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "13,14,15"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    End Sub
    Solution?

    Usually if I clicked debug then it highlights this line ".Refresh BackgroundQuery:=False:"
    Last edited by nguyeda; 02-25-2009 at 06:06 AM.

+ Reply to Thread

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