I have the following code to open my third party file manager at a specific folder, which works, but its not shifting the focus to it, its stays on Access
How do I get the other app to come to hte front?
-----------------------------
Dim vTemp As Variant
Dim vPath As Variant
Dim vString As Variant
vPath = Me.txtPJ_FilePath
vString = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Go " & vPath & ""
'Debug.Print vString
'vbHide 0
'vbNormalFocus 1
'vbMinimizedFocus 2
'vbMaximizedFocus 3
'vbNormalNoFocus 4
'vbMinimizedNoFocus 6
vTemp = Shell(vString, vbNormalFocus)
-------------------------------
I'm expecting vbNornalfocus to shift the focus to the app opened by the shell command, but it does not if the app is already open, which it always is as I keep DO open all the time
I've tried the following two common approaches that test the app is open:
----------------------
Public Sub OpenDirectoryOpus(vPath As Variant)
Dim vString As Variant
vString = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Go " & vPath & ""
Debug.Print vString
'Launch application if not already open
If vPID = 0 Then 'Application not already open
101:
vPID = Shell(vString, vbNormalFocus)
'AppActivate vPID
Else 'Application already open so reactivate
On Error GoTo 101
AppActivate (vPID)
End If
Debug.Print "AppActivate (" & vPID & ")"
End Sub
Public Sub OpenDirectoryOpus2(vPath As Variant)
'Launch folder if not already open
Dim vString As Variant
Dim strDirectory As String
Dim pID As Variant, sh As Variant
Dim w As Object
vString = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Go " & vPath & ""
strDirectory = vPath
On Error GoTo 102:
Set sh = CreateObject("shell.application")
For Each w In sh.Windows
If w.Document.folder.self.path = strDirectory Then 'if already open, activate it
w.Visible = False
w.Visible = True
Exit Sub
End If
Next
'if you get here, the folder isn't open so open it
'vbHide 0
'vbNormalFocus 1
'vbMinimizedFocus 2
'vbMaximizedFocus 3
'vbNormalNoFocus 4
'vbMinimizedNoFocus 6
pID = Shell(vString, vbNormalFocus)
102:
End Sub
-----------------------
Again I was expecting AppActivate to work but it does not.
Surely there is a simple way to get the other app to be the focus?
Thanks in advance
Grant
How do I get the other app to come to hte front?
-----------------------------
Dim vTemp As Variant
Dim vPath As Variant
Dim vString As Variant
vPath = Me.txtPJ_FilePath
vString = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Go " & vPath & ""
'Debug.Print vString
'vbHide 0
'vbNormalFocus 1
'vbMinimizedFocus 2
'vbMaximizedFocus 3
'vbNormalNoFocus 4
'vbMinimizedNoFocus 6
vTemp = Shell(vString, vbNormalFocus)
-------------------------------
I'm expecting vbNornalfocus to shift the focus to the app opened by the shell command, but it does not if the app is already open, which it always is as I keep DO open all the time
I've tried the following two common approaches that test the app is open:
----------------------
Public Sub OpenDirectoryOpus(vPath As Variant)
Dim vString As Variant
vString = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Go " & vPath & ""
Debug.Print vString
'Launch application if not already open
If vPID = 0 Then 'Application not already open
101:
vPID = Shell(vString, vbNormalFocus)
'AppActivate vPID
Else 'Application already open so reactivate
On Error GoTo 101
AppActivate (vPID)
End If
Debug.Print "AppActivate (" & vPID & ")"
End Sub
Public Sub OpenDirectoryOpus2(vPath As Variant)
'Launch folder if not already open
Dim vString As Variant
Dim strDirectory As String
Dim pID As Variant, sh As Variant
Dim w As Object
vString = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Go " & vPath & ""
strDirectory = vPath
On Error GoTo 102:
Set sh = CreateObject("shell.application")
For Each w In sh.Windows
If w.Document.folder.self.path = strDirectory Then 'if already open, activate it
w.Visible = False
w.Visible = True
Exit Sub
End If
Next
'if you get here, the folder isn't open so open it
'vbHide 0
'vbNormalFocus 1
'vbMinimizedFocus 2
'vbMaximizedFocus 3
'vbNormalNoFocus 4
'vbMinimizedNoFocus 6
pID = Shell(vString, vbNormalFocus)
102:
End Sub
-----------------------
Again I was expecting AppActivate to work but it does not.
Surely there is a simple way to get the other app to be the focus?
Thanks in advance
Grant