FSO CopyFolder: sometimes spaces in path?

EdNerd

Active Member
Joined
May 19, 2011
Messages
456
I have a line of code to copy a folder and contents using FileSystemObject (FSO). It works great - until I get a space in the folder name. I'm not sure how to handle this. Any help is appreciated.

In this line, if FldName contains a space, the code errors.
Code:
FSO.CopyFolder FromPath, ToPath2 & "\" & FldName, True\

Ed
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
A space in the folder shouldn't be a problem. However, you have a backslash (\) at the end of your line of code. Is that a typo? Maybe the path to your destination folder is incorrect?
 
Upvote 0
Yah - it's just a typo. Fat fingers are faster than the brain!! It's not in the code.
Well, I'll keep plugging at it then.
Thanks for the reply.

Ed
 
Upvote 0
The string makes up just fine. I'm running this to do backups of files in several folders. It will run just fine - until it hits an odd file - and then it kicks out and skips to the next folder. Then only thng that jumped out at me was the possibility of spaces in the FldName variable.

Doesn't seem to be the problem, though. So I'll keep looking. Thanks for chiming in.

Ed
 
Upvote 0
you seem to know what you are doing so ignore this just putting it out there so has been said

your FldName is declared as a string ?

you have put in a folder name in the FldName and tested it with a temp msgbox ?? just to confirm the string is going into the variable correctly ??
 
Upvote 0
Well, I *thought* everything was making up okay. I mean, I walk through (with F8) and the first fifty or so work just fine. So I figure it's all good and run it. Silly me ....

Going at it differently this time. I'm going to iterate all my folders and write the paths and file names into a worksheet, as well as the strings for where they would wind up. Then I can see where maybe I'm missing a \ or have an extra one, or something like that.

"you seem to know what you are doing" << don't be fooled!! :8>)
If I knew, I'd have this licked by now!

Ed
 
Upvote 0

Forum statistics

Threads
1,215,331
Messages
6,124,311
Members
449,152
Latest member
PressEscape

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