27.07.2023, 12:55
Moin,
API Timer überwacht, ob der VBA-Editor offen ist, oder nicht:
API Timer überwacht, ob der VBA-Editor offen ist, oder nicht:
Code:
Option Explicit
Private Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Private Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long
Private lngTimer As LongPtr
Const TIMERYES = &H113
Public Sub Start_Timer()
lngTimer = SetTimer(0&, 0&, 800, AddressOf V_B_E)
End Sub
Public Sub Kill_Timer()
KillTimer 0&, lngTimer
Tabelle1.Cells(1, 1).Value = vbNullString
End Sub
Private Sub V_B_E(ByVal hwnd As LongPtr, ByVal uMsg As LongPtr, ByVal wParam As LongPtr, ByVal lParam As LongPtr)
On Error Resume Next
Tabelle1.Cells(1, 1).Value = IIf(uMsg = TIMERYES And Application.VBE.MainWindow.Visible, "YES...", "NO...")
On Error GoTo 0
End Sub