Rubrik: VB/VBA | 03.03.02 |
Wie kann ich von Word aus ein Excel-Dokument aufrufen? VB-Version: VB5, VB6 | ||
Views: 7.136 |
Dies geht mit der API ShellExecute relativ einfach:
' Zuerst die benötigten Deklarationen Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" ( _ ByVal hWnd As Long, _ ByVal lOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long
' Der Aufruf erfolgt so: Dim hWnd As Long Dim sExcelFile As String sExcelFile = "c:\pfad\Exceltabelle.xls" hWnd = GetDesktopWindow() ShellExecute hWnd, "Open", sExcelFile, "", "", vbNormalFocus