ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA interrupts... (https://www.excelbanter.com/excel-programming/389482-vba-interrupts.html)

Lyndon[_2_]

VBA interrupts...
 
Hi all,

Does VBA allow process interrupts from a Timer and if so, how is this
implemented..? I have written a simple progress bar in the status bar
and have a timer created using the following API commands:

Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long

When I set the timer it calls my specified on every interval. I was
hoping to use this timer to increment my progress bar.

The task that is taking a while to execute is as follows:

dim rstData as ADODB.Recordset
Set rstData = New ADODB.Recordset

rstData.Open "C:\Temp\outRS.rst"

Opening this persistent recordset takes about 30 seconds and being a
VBA function I cannot access the code that loops and reads in this
recordset to add a DoEvents or the code to update the progress bar. I
was hoping that the Timer I have created would interrupt this process,
call the progress bar update procedure and then resume the load but
this is not the case. How can I implement a progress bar when one
statement takes 30seconds and I want a progress indication of that..?

Thanks in advance,
Lyndon.



All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com