Delaying macro until web query fully loaded.

Please post any questions regarding the program here.

Moderator: 2020vision

Delaying macro until web query fully loaded.

Postby Captain Sensible » Fri Mar 28, 2014 8:17 pm

Is anyone clued up with web queries ? I'm looking for someway to delay the rest of a macro running until the web query has finished loading, obviously I don't want to use some timer as that may mean unnecessary delays or occasions where the web query is slow for whatever reason.

I'm considering maybe a "private sub worksheet_change target as range" kicked off by the data area being populated but surely there must be something within excel to say when the query has been retrieved?

Thanks
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby alrodopial » Fri Mar 28, 2014 9:09 pm

Code: Select all
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby Captain Sensible » Fri Mar 28, 2014 9:16 pm

Thanks I stuck it after the web query code but just got an error "Invalid or unqualified reference"

I'll have a better look after racing see if I can figure out where to stick it in the coding
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby alrodopial » Sat Mar 29, 2014 1:32 am

place it just before the "end with"
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby Captain Sensible » Sun Mar 30, 2014 8:54 pm

Keeps throwing up errors alrodopial, dunno where I'm going wrong tbh

my sub code is just a few lines

Code: Select all
Sub data()


Dim qry As QueryTable
With Sheets("Sheet2")


Set qry = .QueryTables.Add(Connection:="URL;http://localhost/testing/excelgraph.php?ei=" & Sheets("Sheet1").Range("N12").Value & "&race=" & Sheets("Sheet1").Range("A10").Text, Destination:=.Range("A1"))
qry.Refresh


End With



Call bets
End Sub



Hoping to get a delay before the bets routine is called.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby alrodopial » Mon Mar 31, 2014 7:03 am

these may help

http://www.mrexcel.com/forum/excel-ques ... -load.html

http://stackoverflow.com/questions/8925 ... fresh-wait

usually the "with" is connected with the querry and not the sheet (like you did)
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby Captain Sensible » Mon Mar 31, 2014 1:31 pm

Thanks , I t've tweaked a version of this code and seems to be ok. Only time you find out for sure is when things go wrong I suppose :)


Code: Select all
Sub AddWebquery()
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://de.selfhtml.org/html/tabellen/anzeige/table_tr_th_td.htm", _
        Destination:=Range("$A$1"))
        .Name = "table_tr_th_td"
        .BackgroundQuery = False
        .RefreshStyle = xlInsertDeleteCells
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "1"
        .Refresh BackgroundQuery:=False
    End With
End Sub


I need to get some error trapping in there to handle long delays but so far seems fine.

I'm trying to make my sheets more efficient by using VBA and removing as many redundant formulas as possible just cos some only need to run at market change and things like my vlookups were pointless firing every refresh. One thing that dropped the cpu drastically was changing my lookups to the same sheet, maybe I'd referenced things inefficiently with formulas.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby mak » Mon Mar 31, 2014 2:38 pm

i don't know if my thoughts are 100% correct, but the cpu problem has to do mainly with betfair. the same bots working ok for many months are now producing problems.

in a competitive to BA software there are complains regarding high cpu demands also and that can not be a coincidence.

that's why i am asking for the new ba version - in order to be efficient because right now it is not
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Postby Captain Sensible » Mon Mar 31, 2014 3:00 pm

Nah mine was certainly down to my poor coding, managed to get the sheet down to peaking at 10% compared to the 50% it used to do almost continually.

I'm not sure the API-NG is going to cure all your problems mak, it does look like it'll be more efficiently coded for Betfair but doesn't necessarily follow that it'll be more efficient for users and doubt they'll change the current API limits or servers.

The old API isn't due to be phased out until November and you don't see any of the other vendors clambering over themselves to implement it just yet. I'm sure it's still very buggy especially if you take into account Betfair's previous track record so don't expect to have a new version soon. I've got to recode some of my own php bots but can't see any benefits for me so I'll probably only look at it in September when any initial problems have hopefully been ironed out.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby mak » Mon Mar 31, 2014 3:49 pm

as i said, i don't know what is the problem but betfair something has change in their code making BA consume much more cpu than before

i can't run the same bots in the same vps anymore.


for some reason BA and other software has become less efficient
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Postby MiniBlueDragon » Wed Apr 09, 2014 11:14 pm

alrodopial wrote:
Code: Select all
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop


Mine's pretty similar to this.

Code: Select all
Set oDoc = oHTMLDoc.createDocumentFromUrl(strName, "")
Do While oDoc.readyState <> "complete": DoEvents: Loop
MiniBlueDragon
 
Posts: 130
Joined: Tue Jul 05, 2011 1:14 pm
Location: London


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 72 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.

cron