PC Review


Reply
Thread Tools Rate Thread

Code to kill all modal dialogs

 
 
Michael
Guest
Posts: n/a
 
      21st Jun 2007
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 With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      21st Jun 2007
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" <(E-Mail Removed)> wrote in message
news:Od5t$(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modal Dialogs Such as MessageBox Should Appear Above Always-on-Top =?Utf-8?B?Sm9uT2ZBbGxUcmFkZXM=?= Microsoft Dot NET Framework Forms 0 27th Jul 2007 04:02 PM
Looking for sample code that would allow me to kill any modal dialog present in Excel Michael Microsoft Excel Programming 0 23rd May 2007 11:50 PM
modal dialogs not modal cassidyc@gmail.com Microsoft C# .NET 2 5th May 2005 09:41 PM
Submission of modal dialogs Mark Rae Microsoft ASP .NET 2 25th Jul 2004 12:09 AM
Re: WCELOAD Modal Dialogs Alex Feinman [MVP] Microsoft Dot NET Compact Framework 0 22nd May 2004 08:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:06 PM.