Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am searching for easy VBA script to create a folder (C:\LBA\Temp)
if does not exist. Here is a routine I once posted in the compiled VB newsgroups, but it will work in Excel's VBA... Sub MakeDirectories(ByVal PathIn As String) Dim X As Long If Right$(PathIn, 1) < "\" Then PathIn = PathIn & "\" X = InStr(1, PathIn, "\") Do While X < 0 If Dir$(Left$(PathIn, X), vbDirectory) = "" Then MkDir Left$(PathIn, X) End If X = InStr(X & 1, PathIn, "\") Loop End Sub If any part of the path already exists, it will add the part that doesn't exist to the part that already exists. You would use it from your own code like this... MakeDirectories "c:\LBA\Temp" You can chain more than the two subdirectories shown in your example request. For example... MakeDirectories "c:\1stDir\2ndDir\3rdDir\4thDir" Rick |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to create a macro button to exit a program | Excel Worksheet Functions | |||
Save file in a new folder, but create folder only if folder doesn't already exist? | Excel Programming | |||
How do i create a command button or macro to exit Microsoft Excel | Excel Worksheet Functions | |||
Create Folder and Text File in folder | Excel Programming | |||
Create Folder / Copy Folder / Replace | Excel Programming |