Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mkdir variable

Status
Not open for further replies.

h9050892

Programmer
Apr 6, 2006
5
AT
hi,
For archiving my sheets I want to create a date-Directory.
I have a problem to load a pathSTring to a variable and create with that variable a new directory.

I would be happy about a help.
regards,
Matthias


> 'ddir=z.B.:23.12.2005
>
> ' MsgBox "THe old date diractory is " & adir & ""
> 'reading the old directory

> adir = Range("S6")
b = CheckPath(adir)
> If b = True Then
> ' MsgBox "Does the directory " & adir & " exist?!"
> 'MsgBox "THe old is the same as the new!"
> ChDir adir
>
> Else
> 'MsgBox "THe directory " & adir & " does not exist!a new one will be created"
> MkDir adir
ChDir adir
> 'Saving the new date directory in the config-table
>
> Windows("test.xls").Activate
> Sheets("config-table").Select
> Range("S6").Value = " " & adir & " "
> ActiveWorkbook.Save
>
> End If
 
what is the issue you are having ?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
sorry,
issue: Creating a directory in VBA with a variable which is set in the program.

I tried:
Dim adir as String
Dim ddir as String
ddir = "23.12.1997"
adir = "C:\Clients\Archiv\" & ddir & ""

Mkdir adir

thanks,
Matthias Muehlbacher
 
yes - I got that - what is the error ?

If I was to guess I would say that you can't have a folder with periods (.) in it....

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
now I set: ddir = "2006-06-03" or "test"
I got error: "Path not found"

regards,Matthias
 
Do the lower levels C:\Clients\Archiv\ already exist?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
If the lower levels exist then I cannot replicate your issue. Code works fine. All I would mention is that you do not need the "" at the end of

adir = "C:\Clients\Archiv\" & ddir & ""


Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
You may create this procedure:
Code:
Sub myMkDir(strFolderName As String)
On Error Resume Next
Dim a, t As String, i As Integer
a = Split(strFolderName, "\")
t = a(0)
For i = 1 To UBound(a)
  t = t & "\" & a(i)
  MkDir t
Next
End Sub

and then:
myMkDir adir

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PhV,
Your code helped.
Merci, Matthias

Also thanks to Geoff.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top