need help to send orders by VBA

Discussion regarding the spreadsheet functionality of Bet Angel.
Post Reply
flipflop76
Posts: 16
Joined: Sat Nov 07, 2009 9:22 am

Hi,
I wrote a VBA function to send order to betangel/betfair, and it works fine when i execute the function step by step (line by line) in the VBA debugger, but it doesn't work anymore when I execute it from a button or in the debugger without stopping at each line...

My VBA function is very simple, it's just a loop that enable my global flag, clear the status, then orders should be sent and the function will do the next iteration until the end... What happens is the command is indeed copied to the command column (L column), but it is just not executed...

I have been told by BetAngel support to put a lot of "DoEvents" calls in my code to let Excel get new data from betangel, but it doesn't work. I have also tried to put a Application.Wait to give time to the order to be executed until next iteration, and it doesn't work as well...

Any help would be greatly appreciated !

Thanks,
FF
flipflop76
Posts: 16
Joined: Sat Nov 07, 2009 9:22 am

by the way, I use BetAngel v1.23.7, Excel 2007, Windows XP
flipflop76
Posts: 16
Joined: Sat Nov 07, 2009 9:22 am

can anybody help ?
User avatar
TheTub
Posts: 267
Joined: Thu Mar 26, 2009 7:53 pm
Location: Nottinghamshire

Well, it sounds like when your loop is running it is doing so to the exclusion of the rest of the system.

So placing 'DoEvents' in the code should get over this.

Maybe you have not placed them in the right place in the loop?
nigelk
Posts: 469
Joined: Wed Apr 15, 2009 11:00 pm

Is it just failing when the command is put in column L or does it sometimes not get there at all?

Nigel
flipflop76
Posts: 16
Joined: Sat Nov 07, 2009 9:22 am

My commands are simply not executed by betangel, although I believe I have set/cleaned everything correctly, and I am able to send orders from the code when I execute the code line by line in debugging mode... When Excel executes my own VBA code, it is not able to do anything else correctly, even when I put DoEvents in the code.

Now I have tried something else, I have moved my loop that send 3 orders per market into the Worksheet_Calculate() sub, and I have another problem : my VBA code seems to run OK again, but actually some cells in my spreadsheets return #VALUE!, these cells contain a call to another of my own VBA functions. They return a value all the time, except when my Worksheet_Calculate is executed...

Can you please help ? After 1 month, I am still unable to perform the most basic thing : send orders to betfair. And my daily job is to write Excel/VBA spreadsheets in finance... I do believe the Betangel excel API requires very serious improvement, it is simply not professional enough in my (humble) opinion. I have emailed several times the support and they couldn't fix my issue yet.

Thanks for your help,
FF
nigelk
Posts: 469
Joined: Wed Apr 15, 2009 11:00 pm

Do you need an application on time or a loop in a worksheet event?

If you have something in the sheet calculate event, it will fire irrespective of the on time instruction, and if you have a loop, maybe you could re-write it?

In the sample below, both instructions achieve exactly the same thing.

Private Sub Worksheet_Calculate()

For x = 1 To 3
Range("a4") = Range("a4") + 1
Next

Range("a5") = Range("a5") + 3

End Sub

Are you sure the sheet is actually calculating something?
If you put a '6' in cell A1, nothing will happen, as there is nothing to calculate. However, if you put a 'formula' in say for example '=6' then the sheet will calculate and it will fire.

Also, are you turning the events on and off? It could be that you are turning the events off, the code crashes, and it is not being turned on again?

There could be many different things that are causing it to fail, it's hard to say without seeing the code.

Cheers,Nigel
flipflop76
Posts: 16
Joined: Sat Nov 07, 2009 9:22 am

OK I found a solution : I'm not doing anything anymore in the Worksheet_Calculate function, as it seems to intervenes with BetAngel processing.

What I do I start a timer when I want to start my code (by pressing a button), then I do all my processing on the timeout function. I don't really like this way of working because I don't trust timer in Excel, but this is the only way I found.

Thanks for your help,
FF
Post Reply

Return to “Bet Angel - Spreadsheet / Excel chat”