Hi fblaze,
Try the following code:
Sub TestRunWindowsExplorer()
Dim sPathAndFolder As String
sPathAndFolder = ThisWorkbook.Path & "\"
Debug.Print sPathAndFolder 'Output in debugger Immediate Window (CTRL G)
Call RunWindowsExplorer(sPathAndFolder)
End Sub
Sub RunWindowsExplorer(sPathAndFolder As String)
Dim sCommand As String
Dim sLocalPathAndFolder As String
Dim sFolder As String
'Make sure 'Path and Folder' have a trailing 'backslash'
'Enclose name in quadruple quotes to allow spaces in folder names
sLocalPathAndFolder = sPathAndFolder
If Right(sLocalPathAndFolder, 1) <> "\" Then
sLocalPathAndFolder = sLocalPathAndFolder & "\"
End If
sLocalPathAndFolder = """" & sLocalPathAndFolder & """"
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Open Windows Explorer for the Desired Folder
'''''''''''''''''''''''''''''''''''''''''''''''''''
' Shell "cmd /c " & sPath & " & pause ", vbMaximizedFocus
'Windows Explorer options see: http://support.microsoft.com/kb/152457
' /e Opens Windows Explorer in its default view.
' /n Opens a new single-pane window for the default selection.
'
' /root,<object> Opens a window view of the specified object.
' /select,<object> Opens a window view with the specified folder, file or application selected.
sCommand = "explorer /root," & sLocalPathAndFolder & " /select, " & sLocalPathAndFolder
Call Shell(sCommand, vbNormalFocus)
End Sub
Public Sub LjmOpenRecycleBinInWindowsExplorer()
'This will Open the Windows Recycle Bin in a 'Normal' Window.
'To use a maximized window use 'vbMaximizedFocus'.
'
'The string ending in '954e' is the 'Recycle Bin' CLSID.
'
'For additional 'CLSID' information see: http://www.autohotkey.com/docs/misc/CLSID-List.htm
'
'Windows Explorer options see: http://support.microsoft.com/kb/152457
' /e Opens Windows Explorer in its default view.
' /n Opens a new single-pane window for the default selection.
'
' /root,<object> Opens a window view of the specified object.
' /select,<object> Opens a window view with the specified folder, file or application selected.
Dim sCommand As String
sCommand = "explorer /e,::{645ff040-5081-101b-9f08-00aa002f954e}"
Call Shell(sCommand, vbNormalFocus)
End Sub
Lewis
Bookmarks