Problems with spaces in File/Path name

RichFost

New Member
Joined
May 13, 2004
Messages
26
Hi,

I'm trying to use the code below in a macro to open a folder in an explorer window, but as the folder i'm trying to open has spaces in it's name (i.e. S:\My Work File) it won't work...I get the error message "The path does not exist or is not a directory". :

retval = Shell("explorer.exe s:\My Work File", vbNormalFocus)

If I remove the spaces (i.e. S:\MyWorkFile) it works.

However, the folder is a centrally used one in my company and canot be renamed as it will affect loads of other peoples spreadsheets.

Any ideas how I can get this to work without changing the folder name?

Thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Yep, the actual folder name & location is:

s:\The Sales Centre\Sales Support

If I change this to

s:\TheSalesCentre\SalesSupport
or
s:\The_Sales_Centre\Sales_Support

it works ok.

But I can't change the folder names as i'd annoy several hundred people in my company who also use those folders !
 
Upvote 0
In your original example, you could try this:

retval = Shell("explorer.exe s:\" & chr(34) & "My Work File" & chr(34), vbNormalFocus)

Don't know if this will work, however, and haven't tested it.

Richard
 
Upvote 0
I tried your suggestion Richard in the format below

retval = Shell("explorer.exe s:\" & Chr(34) & "The Sales Centre\Sales Support" & Chr(34), vbNormalFocus)

and I got a pop up box with the error message

The path 's:\The Sales Centre\Sales Support' does not exist or is not a directory.

Man is this frustrating !!!! :confused:

Guess that's why we all love Excel so much. Thanks for trying....
 
Upvote 0
Rich

As a last guess, try this:

Code:
retval = Shell("explorer.exe s:\" & Chr(34) & "The Sales Centre" & chr(34) & "\" & chr(34) & "Sales Support" & Chr(34), vbNormalFocus)

Richard
 
Upvote 0
Nope, still get the same error message. Thanks though.

Is there another way I could go about this ?

Thanks.
 
Upvote 0

Forum statistics

Threads
1,203,380
Messages
6,055,098
Members
444,761
Latest member
lneuberger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top