I need to create a new folder using a folder name in a given cell (ex: A1).
Can I create a macro that will make the new folder (ex: c:/program files/A1)?
thanks in advance
I need to create a new folder using a folder name in a given cell (ex: A1).
Can I create a macro that will make the new folder (ex: c:/program files/A1)?
thanks in advance
Hello Rsabot,
Use MkDir "C:\Program Files\A1"
Sincerely,
Leith Ross
Take a look at the MkDir method in VBA Help.
Const sPATH As String = "C:/Program Files/"
MkDir sPath & Range("A1").Value
In article <[email protected]>,
rsabot <[email protected]> wrote:
> I need to create a new folder using a folder name in a given cell (ex: A1).
> Can I create a macro that will make the new folder (ex: c:/program files/A1)?
>
> thanks in advance
Sub CreateFolderUsingRangeValue()
Dim ObjA, NewFolder
Const RootFolder As String = "c:\program files"
NewFolder = RootFolder & "\" & Sheet1.Range("A1").Value 'suppose you want to
refer to sheet1
Set ObjA = CreateObject("scripting.filesystemobject")
If ObjA.folderexists(NewFolder) = True Then 'check if folder exist therein,
if yes, exist sub or do sthing else...
If MsgBox("Folder Exists, do you want to erase it?", vbYesNo, "Critical
Infor...") = vbNo Then
'do sthing here, else directly create folder as following
Exit Sub
Else
ObjA.deletefolder (NewFolder) 'delete old folder and create new one.
ObjA.createfolder (NewFolder)
End If
Else
ObjA.createfolder (NewFolder)
End If
End Sub
--
a scientist
"JE McGimpsey" wrote:
> Take a look at the MkDir method in VBA Help.
>
> Const sPATH As String = "C:/Program Files/"
> MkDir sPath & Range("A1").Value
>
>
> In article <[email protected]>,
> rsabot <[email protected]> wrote:
>
> > I need to create a new folder using a folder name in a given cell (ex: A1).
> > Can I create a macro that will make the new folder (ex: c:/program files/A1)?
> >
> > thanks in advance
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks