AW: gibt's nicht owT
17.03.2011 14:36:34
Nepumuk
Hallo,
lässt sich aber mit einem Timer relativ leicht verwirklichen:
' **********************************************************************
' Modul: DieseArbeitsmappe Typ: Element der Mappe(Sheet, Workbook, ...)
' **********************************************************************
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call prcStop
End Sub
Private Sub Workbook_Open()
Call prcStart
End Sub
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Option Private Module
Private Declare Function SetTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private blnActiv As Boolean
Public Sub prcStart()
blnActiv = True
Call SetTimer(Application.hwnd, 0, 500, AddressOf prcTimer)
End Sub
Public Sub prcStop()
Call KillTimer(Application.hwnd, 0)
End Sub
Private Sub prcTimer(ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
If GetActiveWindow = Application.hwnd Then
If Not blnActiv Then
Call prcYour_Procedur 'Aufruf deiner Prozedur
blnActiv = True
End If
Else
blnActiv = False
End If
End Sub
Private Sub prcYour_Procedur() 'Deine Prozedur
Static intIndex As Integer
intIndex = intIndex + 1
MsgBox "Excel agree focus " & CStr(intIndex) & ". time", 64, "Info"
End Sub
Gruß
Nepumuk