David Sinclair
07-31-2006, 12:24 PM
Would someone provide advice on how to have Windows Explorer open in a particular folder. The code below works as long as the folder name does not have characters in the folder name, e.g. commas.
Sub OpenExplorer()
Dim strFolderName As String
strFolderName = "C:\Demo, Level1"
Shell "Explorer.exe /e, /root," & strFolderName
End Sub
ghudson
08-09-2006, 06:24 PM
No, but you could use a custom browser function in your application if that will help your users.
Browse [Find a directory or file] (http://www.access-programmers.co.uk/forums/showthread.php?t=97787)
ghudson
08-09-2006, 06:28 PM
I once had a similar problem with file names that had a comma within the file name on a server. See if you can modify the code at this thread to meet your needs for I doubt a comma in a directory name is really necessary. Renaming Network Files (http://www.access-programmers.co.uk/forums/showthread.php?t=73500)
Birger Bjerkeng
05-08-2007, 06:43 AM
In order to have the Explorer open with a directory path containing comma, ensure that the foldername string is stored as quoted text, beginning and ending with ". To get the example mentioned to work, write
strFolderName = """C:\Demo, Level1"""
The Shell command string
"Explorer.exe /e, /root," & strFolderName
will then be:
Explorer.exe /e, /root,"C:\Demo, Level1"
and the comma is interpreted as part of the directory
instead of a command parameter separator
Alternatively (maybe better), keep the strFolderName as it is, and build the Shell command with
"Explorer.exe /e, /root,""" & strFolderName & """
GaryPanic
05-08-2007, 07:11 AM
This is something that I have been looking at and I cannot wrap my head around this
GH solution looks very good -
but I could not get it to work 100% - so I parked this for some time - until i had a clear moment - still parked - this solution GH is visually pretty good - and is the one i prefer -
sorry i cannot shed any light on the matter-
soporific
10-30-2008, 04:05 PM
Hi everyone,
I've been using google to find answers to my Access problems and its about time i gave something back.
If you have a variable with a comma in it, and you need to perform file or directory commands, you will encounter probs. Here's how i got around it - this will open up an explorer window at the location contained by the variable zPath:
Dim zPath, RetVal
zPath = "C:\temp, 1"
RetVal = Shell("Explorer.exe """ & zPath & """", vbNormalFocus)
Hope this helps!