ich habe noch ein problem - ich habe in ein Exceltabellenblatt einen Button gelegt, der bei klick exakt diesen prozess ausführen soll:
C:\Programme\Gams22.5\gams trnsport
ich habe zum auslösen des Prozesses durch "klick" auf den Button folgenden Quelletext:
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Declare Function FreeConsole Lib "kernel32" () As Long
Private Declare Function AllocConsole Lib "kernel32" () As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO)
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal PtrProcessAttributes As Long, ByVal PtrThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal_hObject As Long) As Long
Private Sub CommandButton1_Click()
Dim startup_info As STARTUPINFO
Dim process_info As PROCESS_INFORMATION
Dim command As String
Dim result As Long
Dim txt As String
Dim console As Long
Const SW_SHOWNORMAL = 1
Const STARTF_USESHOWWINDOW = &H1
Const NORMAL_PRIORITY_CLASS = &H20
GetStartupInfo startup_info
startup_info.wShowWindow = SW_SHOWNORMAL
startup_info.dwFlags = startup_info.dwFlags Or STARTF_USESHOWWINDOW
command = "gams trnsport"
result = CreateProcess(vbNullString, command, 0, 0, 0, NORMAL_PRIORITY_CLASS, 0, "c:\ _
programme\Gams22.5\", startup_info, process_info)
If result = 0 Then
result = GetLastError()
txt = "Error code: " + Str(result)
MsgBox txt
End If
CloseHandle (process_info.hThread)
CloseHandle (process_info.hProcess)
End Sub
wenn ich den button drücke, dann kommt immer "error code: 0"
ich habe schon sämtliche varianten ausprobiert - kein erfolg. Woran kann das liegen, kann mir jemand helfen oder mich auf alternativen verweisen?
Viele Grüße
Michael