Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to create a folder and copy files GainesvilleWes New Users to Excel 2 February 26th 07 06:33 PM
Macro to create a new folder according to the month Dolphin Excel Discussion (Misc queries) 5 December 15th 06 01:31 PM
Create folder with a macro Myrna Rodriguez Excel Programming 3 June 28th 04 10:34 PM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM
Macro to create folder yo beee Excel Programming 1 October 21st 03 02:10 AM


All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"