Stop

  • Thread starter Thread starter GOU
  • Start date Start date
G

GOU

Hi,

I was wondering if there's a way to use the reserved
word "Stop" in VBA code and have a way to continu the
execution whitout having the user's intervention (like
pressing "F5").

Thanks.
 
To be more explicit,

I'm using an AddIn to retreive information from a Reuters
terminal. When I execute my sub "Step by Step", all is
working well and I can retreive my value. But if I run the
sub ("F5") I have an error message telling me it didn't
recognise one item. I respond to this message by
pressing "F5" to continu and it can run till the end with
no error.

I tought the problem was just a mather of time so the
AddIn can retreive the data, so I try to add a loop in my
code. Even after a 1 minute loop, it still not work. So I
was thinking of a way to stop the execution for a moment,
as if the CPU focus wasn't on the execution of my sub and
start from there to complete the execution.

I hoping to have some answer from Reuters but till then
I'm trying all I can to find a way to copy my data in an
Access table.

Thanks.
 
Try adding in the lin
DoEvent
at the point before it produces the error

Depending on what happens with the error... possibl
On Error Resume Nex
might be an option

Basil
 
Try to put DoEvents into your wait loop or if that does not work, WinAPI
function Sleep.

Alex.
 
With the recommandation of Basil and Alex, I've tried to
add "DoEvents" in my code but it still doesn't work.

Alex gave me another trick "WinAPI function Sleep" but I
don't understand how to use it ? Should I add a reference ?
Should I use "Shell" to call something outside Access ?

Thanks.
 
Put the line below somewhere at the top of your code window (after Options,
if any)
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
and then just call it
Sleep 1000 ' Wait one second

Alex.
 
Hi Alex,

Thank you for the code. I've tried it but unfortunately it
still doesn't work. I really have to sit down with the
guys from Reuters to understand what is the problem.

I will surely use your Sleep sub for other reason and as
soon as I got an answer on my problem, I'll post a respond.

Gou.
 
Finally,

Basil and Alex were both right with DoEvents.

At my first test I did nothing to control the Error
"On Error Goto 0" and I placed "DoEvents" just before the
line giving me an error.

Then a few tests later I started controlling the error
and wrote "DoEvents" in the Error zone and that finally
worked.
Ex.
Sub CopyDataFromReuteurs()
On Error GoTo WhatToDo:
Dim varReutersData as Variant

...

ErrorLine:
varReutersData = list.value("CAD=", "BID")

Exit Sub

WhatToDo:
DoEvents
Resume ErrorLine:
End Sub

Thanks for your help.
 
Hi Gou!

Just a very little and not very important completition:
ErrorLine:
varReutersData = list.value("CAD=", "BID")

Exit Sub

WhatToDo:
DoEvents
Resume ErrorLine:
End Sub

If you use only the word "Resume" it will continue with the line which
raised the error, "Resume Next" will execute the following line. So there's
no need for your "ErrorLine:"

Well, not very important...

CU
Gottfried
 
Back
Top