space

slimjen1

Registered User.
Local time
Today, 14:18
Joined
Jun 13, 2006
Messages
562
All, using access 2010. I am using this code to make a folder upon exporting a query to excel:

Code:
sPath = "C:\Directory\mainfolder\" & Format(Date, "yyyy mm dd") & "folder"
MkDir sPath

It works however I need a space between the date and the folder. But when I use "\", it tells me path doesn't exist. Please help me get a space in the name when creating the folder. Thanks
 
slimjen1 and her very short titles "space" ;)

It's telling you that mainfolder doesn't exist. You need to use Shell's MkDir because VBA's MkDir can't create non-existent subdirectories.
 
slimjen1 and her very short titles "space" ;)
QUOTE]

Ha Ha Ha "short and sweet":)

I get the folder created but it creates: 2014 08 12Folder. I want a space between the 12 and folder.

I was just trying it with "\" but I get the error. Without; I do not get the error. Thanks
 
When you use backslash where? If you mean "\2014 08 12\Folder", it's again telling you that the subdirectory "2014 08 12" doesn't exist and it can't create it.
 
Code:
sPath = "C:\Directory\mainfolder\" & Format(Date, "yyyy mm dd") & "\" &"folder"
MkDir sPath
 
If I understand what you want, try this:
Code:
sPath = "C:\Directory\mainfolder\" & Format(Date, "yyyy mm dd") [COLOR=red]& " " &[/COLOR] "folder"
 
That's what I'm talking about, you're trying to create two directories, "2014 08 12" (the subdirectory) and "folder" (the main directory). MkDir in VBA cannot create subdirectories. However, MkDir in Shell() can.
 
I think BigHappyDaddy may have understood your requirement. I just assumed it was too trivial for you.
 
that did it. I knew it was something simple. Thanks vbaInet and BigHappyDaddy for responding:)
 

Users who are viewing this thread

Back
Top Bottom