View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Michael[_44_] Michael[_44_] is offline
external usenet poster
 
Posts: 31
Default Code to kill all modal dialogs

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