Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal _
lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Public Function OpenWordForeground(cWordDoc As String)
'Worddokument in den Vordergrund holen wenn bereits geöffnet oder im Vordergrund öffnen
On Error GoTo Err_OpenWordDoc
Dim HwndDeskTop
Dim HwndWord As Long
Dim Ret As Long
HwndWord = FindWindow("OpusApp", vbNullString)
If HwndWord <> 0 Then
SetForegroundWindow HwndWord
SetActiveWindow HwndWord
Else
HwndDeskTop = GetDesktopWindow
End If
Ret = ShellExecute(HwndDeskTop, "Open", cWordDoc, 0&, 0&, SW_SHOWMAXIMIZED)
Exit_OpenWordDoc:
Exit Function
Err_OpenWordDoc:
MsgBox "Fehlernummer: " & Err.Number & vbCrLf & _
"Fehlerbeschreibung: " & Err.Description, _
vbCritical, "Fehler in Public Function OpenWordDoc"
Resume Exit_OpenWordDoc
End Function
Word mit einem Makro in Excel starten
Drehbank69 12.11.2007 - 163 Hits - 2 Antworten
Word Dokument in Excel-Tabelle anzeigen lassen
Gras 28.01.2008 - 67 Hits - 1 Antwort
Querverweis Excel auf Word?
Flopchen 17.06.2008 - 49 Hits - 6 Antworten
Hyperlink aus Excel in Seriendruck in Word
Mlen 10.10.2008 - 5 Hits - 1 Antwort