Unexpected error!

Please post any questions regarding the program here.

Moderator: 2020vision

Unexpected error!

Postby Royville » Fri Aug 12, 2011 10:20 am

Hi,

I keep getting the message - Run-time error '1004' - at seemingly random times when placing bets through Excel.

It appears to be happening when excel is downloading data from the racing post web site. A message box pops up (Run-time error '1004') saying that an unexpected error has occurred. When I click debug it then points to the same line of code every time

ConnectString = "URL;" & myURL
Sheet5.Cells.ClearContents
With Sheet5.QueryTables.Add(Connection:=ConnectString _
, Destination:=Sheet5.Range("A1"))
.Name = "NextRace"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
'.WebDisableRedirections = False
.Refresh BackgroundQuery:=False <----- error here!
End With

Anyone got any ideas on what may be causing it? - Or better still is there any way to ignore the error and retry?

Thanks,
Roy.
Royville
 
Posts: 65
Joined: Wed Apr 21, 2010 4:50 pm
Location: UK Midlands

Postby osknows » Fri Aug 12, 2011 3:23 pm

Hi Roy,

An error 1004 could be lots of different things so it's hard to say what's causing it without being able to replicate it. If you're not too fussed about what's causing the error use the following

Code: Select all
ConnectString = "URL;" & myURL
Sheet1.Cells.ClearContents

On Error Resume Next
With Sheet1.QueryTables.Add(Connection:=ConnectString _
, Destination:=Sheet1.Range("A1"))
.Name = "NextRace"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
'.WebDisableRedirections = False
.Refresh BackgroundQuery:=False '<----- error here!
End With
On Error GoTo 0

xSheetCount = ThisWorkbook.Sheets.Count
For s = 1 To xSheetCount
    xQTCount = Sheets(s).QueryTables.Count
    For q = 1 To xQTCount
        Sheets(s).QueryTables(q - n).Delete
        n = n + 1
    Next q
Next s
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Postby Royville » Sat Aug 13, 2011 12:11 pm

Hi Osknows,

Thanks for the reply. I have absolutly no idea what is causing the error, but I will try your code over the weekend and let you know how it goes.

Many thanks
Royville
Royville
 
Posts: 65
Joined: Wed Apr 21, 2010 4:50 pm
Location: UK Midlands

Postby Royville » Mon Aug 15, 2011 2:51 pm

Hi Osknows,

I tried your code over the weekend but it seemed to make the worse.
I did a bit of reading up about error trapping and at the moment I'm just using the code:

On Error Resume Next
my code
On Error GoTo 0

which does seem to be working so I'll see how it goes over time.

Many thanks
Royville
Royville
 
Posts: 65
Joined: Wed Apr 21, 2010 4:50 pm
Location: UK Midlands


Return to Help

Who is online

Users browsing this forum: Google [Bot] and 84 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.