A
ALESSANDRO Baraldi
I from IT.
I use this Function to Shell the Applications i need, but the strange thing
is that if also I open the App
passing VbAppWinStyle this does not maintain the Focus, and don't use my
Parameter.
I need to Click on Task_Bar to PutFocus on it.
I use this Method because i can Shell any Application, and i need to return
PID process to convert on Hwnd.
Any one know why or have some other solution to try....?
Thanks.
Alessandro(IT)
W2K + A_XP
'My Module Function
Public Function OpenApp(strApp As String, Optional eWindowStyle As
VBA.VbAppWinStyle = vbNormalFocus) As Long
On Error GoTo OpenDoc_Err
Dim retval
Dim CmdLn As String
Dim Pid As Long
Dim hwndWindow As Long
Dim retExec As String
Dim tmpAPP As String
Dim ApplicationPaht As String
DoCmd.Hourglass True
ApplicationPaht = GetPathPart(strApp)
tmpAPP = strApp
If retExtension(tmpAPP) = "Exe" Then
CmdLn = tmpAPP
Else
retExec = fFindEXE(tmpAPP, ApplicationPaht)
If Not IsNothing(retExec) Then
CmdLn = retExec & " " & Chr(34) & tmpAPP & Chr(34)
Else
MsgBox "Nessun Eseguibile associato all'allegato...!", vbCritical,
"Avviso"
hwndWindow = 0
GoTo Exit_Here
End If
End If
Pid = Shell(CmdLn, eWindowStyle)
hwndWindow = InstanceToWnd(Pid)
Exit_Here:
OpenApp = hwndWindow
DoCmd.Hourglass False
Exit Function
OpenDoc_Err:
Resume Exit_Here
End Function
I use this Function to Shell the Applications i need, but the strange thing
is that if also I open the App
passing VbAppWinStyle this does not maintain the Focus, and don't use my
Parameter.
I need to Click on Task_Bar to PutFocus on it.
I use this Method because i can Shell any Application, and i need to return
PID process to convert on Hwnd.
Any one know why or have some other solution to try....?
Thanks.
Alessandro(IT)
W2K + A_XP
'My Module Function
Public Function OpenApp(strApp As String, Optional eWindowStyle As
VBA.VbAppWinStyle = vbNormalFocus) As Long
On Error GoTo OpenDoc_Err
Dim retval
Dim CmdLn As String
Dim Pid As Long
Dim hwndWindow As Long
Dim retExec As String
Dim tmpAPP As String
Dim ApplicationPaht As String
DoCmd.Hourglass True
ApplicationPaht = GetPathPart(strApp)
tmpAPP = strApp
If retExtension(tmpAPP) = "Exe" Then
CmdLn = tmpAPP
Else
retExec = fFindEXE(tmpAPP, ApplicationPaht)
If Not IsNothing(retExec) Then
CmdLn = retExec & " " & Chr(34) & tmpAPP & Chr(34)
Else
MsgBox "Nessun Eseguibile associato all'allegato...!", vbCritical,
"Avviso"
hwndWindow = 0
GoTo Exit_Here
End If
End If
Pid = Shell(CmdLn, eWindowStyle)
hwndWindow = InstanceToWnd(Pid)
Exit_Here:
OpenApp = hwndWindow
DoCmd.Hourglass False
Exit Function
OpenDoc_Err:
Resume Exit_Here
End Function