Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I create a new folder using a macro
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I create a new folder using a macro
Take a look at the MkDir method in VBA Help.
Const sPATH As String = "C:/Program Files/" MkDir sPath & Range("A1").Value In article , rsabot 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
i always use filesystemobject to do this,
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 , rsabot 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to create a folder and copy files | New Users to Excel | |||
Macro to create a new folder according to the month | Excel Discussion (Misc queries) | |||
Create folder with a macro | Excel Programming | |||
Create Folder and Text File in folder | Excel Programming | |||
Macro to create folder | Excel Programming |