Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code
Public TimerID1 As Long Public TimerSeconds1 As Single Sub StartTimer() ' Run the timer procedure every second TimerSeconds1 = 1 ' how often to "pop" the timer. TimerID1 = SetTimer(0&, 0&, TimerSeconds1 * 1000&, AddressOf TimerProc1) End Sub Sub TimerProc1(ByVal HWnd As Long, ByVal uMsg As Long, _ ByVal nIDEvent As Long, ByVal dwTimer As Long) Call CountUp End Sub Sub CountUp() ThisWorkbook.Sheets("Sheet1").Activate Range("B5").Select Selection.Value = Selection.Value + 1 End Sub While the code runs if I try to bring any modal dialog (E.g. File -- Saves As or attempt to refresh a PivotTable on the same workseet), Excel crashes! What I want to do is to execute some code to kill any modal dialogs before I execute the code inside the StartTime sub. Any sample code for this? Thanks in advance Michael |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michael,
You didn't include your declaration(s), but I assume: Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long I suppose you have a Kill Timer also: Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Not sure, but as you are not specifying a hwnd for the Timer, it has no connection with the Excel app. Also, did you try the code without the .Activate/.Select ? e.g. With ThisWorkbook.Sheets("Sheet1").Range("B5"). .Value = .Value + 1 End With However, Karl has a Timer class you may want to try: http://vb.mvps.org/samples/project.asp?id=TimerObj NickHK "Michael" wrote in message ... I have the following code Public TimerID1 As Long Public TimerSeconds1 As Single Sub StartTimer() ' Run the timer procedure every second TimerSeconds1 = 1 ' how often to "pop" the timer. TimerID1 = SetTimer(0&, 0&, TimerSeconds1 * 1000&, AddressOf TimerProc1) End Sub Sub TimerProc1(ByVal HWnd As Long, ByVal uMsg As Long, _ ByVal nIDEvent As Long, ByVal dwTimer As Long) Call CountUp End Sub Sub CountUp() ThisWorkbook.Sheets("Sheet1").Activate Range("B5").Select Selection.Value = Selection.Value + 1 End Sub While the code runs if I try to bring any modal dialog (E.g. File -- Saves As or attempt to refresh a PivotTable on the same workseet), Excel crashes! What I want to do is to execute some code to kill any modal dialogs before I execute the code inside the StartTime sub. Any sample code for this? Thanks in advance Michael |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to kill the zipped files in C:\Document and Settings\LogginName\Temp\ using code for this strange Problem | Excel Discussion (Misc queries) | |||
Looking for sample code that would allow me to kill any modal dialog present in Excel | Excel Programming | |||
Kill a process - Could someone check this code for me | Excel Programming | |||
Forms that are modal in 97 are not modal in 2003 | Excel Discussion (Misc queries) | |||
Forms that are modal in 97 are not modal in 2003 | Excel Programming |