dimanche 11 février 2018

web query initialization of data source failed

I have a web query that works great, except that I haven't yet found the secret of creating a variable for the table date so I can loop to get multiple tables. Here's the code (down to the ampersand following the date) that works with one date:

ActiveWorkbook.Queries.Add Name:="Table 0", Formula:= "let" & Chr(13) & 
    "" & Chr(10) & "    Source = web.Page(Web.Contents _
    (""http://www.nasdaq.com/earnings/earnings-calendar.aspx? _
    date=2018-Feb-13))," &

Pay no attention to the line breaks. There are none in the actual code.

The variable I need stands for 2018-Feb-13, but everything I've tried results in runtime error 1004 (Application-defined or Object-Defined error) at the .Refresh BackgroundQuery:=False line just before End With near the bottom. So far, my 20 or 30 variations . . . including different numbers of quotes, and including (or not) the double parentheses after the date . . . have all failed.

If someone could clue me in on the proper variable I'd be more than grateful.




Aucun commentaire:

Enregistrer un commentaire