+ Reply to Thread
Results 1 to 4 of 4

How do I create a new folder using a macro

  1. #1
    rsabot
    Guest

    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. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Rsabot,

    Use MkDir "C:\Program Files\A1"

    Sincerely,
    Leith Ross

  3. #3
    JE McGimpsey
    Guest

    Re: 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 <[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


  4. #4
    zhuge
    Guest

    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 <[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

    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1