Gruppe
API
Problem
Der Kommandozeilen-Pfad von Excel wird ermittelt und Excel wird gestartet.
StandardModule: Modul1
Declare Function GetCommandLine Lib "kernel32" _
Alias "GetCommandLineA" () As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(lpvDest As Any, lpvSource As Any, ByVal NumBytes As Long)
Sub NewExcelInstanz()
Dim sShell As String
sShell = VBACommand
If sShell <> "....." Then
Shell VBACommand, vbMaximizedFocus
End If
End Sub
Function VBACommand() As String
Dim Buffer() As Byte
Dim Addr As Long
Dim sTemp As String
Dim i As Long
Const BufferLen = 256
ReDim Buffer(0 To BufferLen - 1)
Addr = GetCommandLine()
CopyMemory Buffer(0), ByVal Addr, BufferLen
sTemp = StrConv(Buffer(), vbUnicode)
i = InStr(sTemp, Chr$(0))
If i > 0 Then
VBACommand = Left$(sTemp, i - 1)
Else
VBACommand = sTemp & "....."
End If
End Function