Tipster007
Technical User
Hi all,
I have a button on a form to open Windows Explorer and select a file variable set in the code. I want to pause the execution of the code while the Explorer window is open.
I am using WScript.Shell as below but the code continues to run, Explorer opens and correctly selects the file. It works fine when opening Paint or Calculator but won't work for Win Explorer.
I need Windows explorer to open not a file dialog box.
I am using Access 2013 and Windows 8.1. Code below courtesy of many VBA experts.
Thank you in advance smile
Dim strImgPath As String
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 3
Dim errorCode As Integer
strImgPath = Me.txtImageName
errorCode = wsh.Run("explorer.exe /Select, " & """" & strImgPath & """", windowStyle, waitOnReturn)
If errorCode = 0 Then
'Insert code here
Else
MsgBox "Program exited with error code " & errorCode & "."
End If
I have a button on a form to open Windows Explorer and select a file variable set in the code. I want to pause the execution of the code while the Explorer window is open.
I am using WScript.Shell as below but the code continues to run, Explorer opens and correctly selects the file. It works fine when opening Paint or Calculator but won't work for Win Explorer.
I need Windows explorer to open not a file dialog box.
I am using Access 2013 and Windows 8.1. Code below courtesy of many VBA experts.
Thank you in advance smile
Dim strImgPath As String
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 3
Dim errorCode As Integer
strImgPath = Me.txtImageName
errorCode = wsh.Run("explorer.exe /Select, " & """" & strImgPath & """", windowStyle, waitOnReturn)
If errorCode = 0 Then
'Insert code here
Else
MsgBox "Program exited with error code " & errorCode & "."
End If