RunToTheHills
asked on
Open a folder with code
I would like to open a folder thru code
X="C:\WINDOWS\"
Shell X
this does not work
am i going about this the wrong way?
X="C:\WINDOWS\"
Shell X
this does not work
am i going about this the wrong way?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
forgot to include
CONST SW_SHOWMAXIMIZED = 3
CONST SW_SHOWMAXIMIZED = 3
ASKER
Michael D
your code works fine just wondering why i need the space after explorer before the last quotation
your code works fine just wondering why i need the space after explorer before the last quotation
Because this space divides command and parameter:
Actually should be "C:\WINDOWS\explorer.exe" & Space(1) & FolderName
Actually should be "C:\WINDOWS\explorer.exe" & Space(1) & FolderName
Because otherwise your command would be
Shell "explorerC:\WINDOWS\" , vbNormalFocus
explorer is the program, X, or "C:\Windows" is a command line argument
Shell "explorerC:\WINDOWS\" , vbNormalFocus
explorer is the program, X, or "C:\Windows" is a command line argument
ASKER
thank you
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Public Sub ExploreFolder(FolderName As String)
On Error Resume Next
Dim X As Long
X = ShellExecute(0&, "Explore", FolderName, 0&, 0&, SW_SHOWMAXIMIZED)
End Sub
Usage:
Call ExploreFolder("c:\windows"
Good Luck
-Brian