I am writing code for an excel sheet, which constantly polls another application for information. I am having problems being able to interrupt this. My excel version, as far as I know, is Excel 2007
I did a quick search and came up with this code
When I run this, I can interrupt it for a certain amount of time, but as soon as Excels menu bar changes to "Not Responding", Excel whites out, I cant interrupt at all and have to shut down the program and restart. Why does it only work for a certain amount of time, and how do I get round this problem?
I have the same problem when I run this code with my code which polls the application. I can interrupt it for the first few seconds, then I get "Not Responding" and when I click on the Excel sheet it whites out.
thanks for any help
I did a quick search and came up with this code
Code:
Public Sub Start()
On Error Goto UserInterrupt
Application.EnableCancelKey = xlErrorHandler
For i = 1 To 10000000
For t = 1 To 10000
Next t
Next i
Exit Sub
UserInterrupt:
If Err = 18 Then
If MsgBox("Stop processing?", vbYesNo) = vbNo Then
'Keep running at the point procedure was interrupted
Resume
Else
'Handle other errors that occur
'MsgBox Error(Err )
End If
End If
End Sub
When I run this, I can interrupt it for a certain amount of time, but as soon as Excels menu bar changes to "Not Responding", Excel whites out, I cant interrupt at all and have to shut down the program and restart. Why does it only work for a certain amount of time, and how do I get round this problem?
I have the same problem when I run this code with my code which polls the application. I can interrupt it for the first few seconds, then I get "Not Responding" and when I click on the Excel sheet it whites out.
thanks for any help