Gruppe
Extern
Bereich
PowerPoint
Thema
Beim Öffnen PowerPoint starten und danach Mappe aktivieren
Problem
Beim Laden der Arbeitsmappe soll Powerpoint gestartet und nach dessen Beendigung die Mappe wieder aktiviert werden.
Lösung
Geben Sie den Ereigniscode in das Klassenmodul der Arbeitsmappe ein.
ClassModule: DieseArbeitsmappe
Private Sub Workbook_Open()
Call Win32WaitTilFinished("powerpnt.exe")
End Sub
StandardModule: basMain
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const WAIT_TIMEOUT = &H102&
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Sub Win32WaitTilFinished(ProgEXE As String)
Dim ProcessID As Long
Dim hProcess As Long
Dim RetVal As Long
ProcessID = Shell(ProgEXE, vbMaximizedFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID)
Do
DoEvents
RetVal = WaitForSingleObject(hProcess, 50)
Loop Until RetVal <> WAIT_TIMEOUT
End Sub