Consulting

Results 1 to 6 of 6

Thread: Solved: Create new folder

  1. #1

    Solved: Create new folder

    I need to create a new folder in code based upon the first
    5 characters of a newly created table omitting the three
    characters tbl. Eg. So the new table is tblSuppliers. A new
    folder on the hard disk would become c:\database\suppl and
    so on.

    Any help anyone greatly appreciated.

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Here's a straightforward approach[VBA]Dim strFolderName As String

    'initialize variable with table name
    strFolderName = "tblSuppliers"

    'trim off prefix
    strFolderName = Right(strFolderName, Len(strFolderName) - 3)
    'get first 5 letters
    strFolderName = Left(strFolderName, 5)

    'change drive and directory
    ChDrive "C"
    ChDir "c:\database"

    'create directory
    MkDir strFolderName[/VBA]You might want to look at using the FileSystemObject if you do any other file or folder manipulation - it has the added bonus of making it easy to check if files/folders exist
    K :-)

  3. #3

    create new folder

    Well thanks for that Killian

    I'll give that a try right now.
    I'll keep you posted

  4. #4
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    jmentor, can we mark this solved?

  5. #5

    Solved

    Thank you.

    Is it resolved

  6. #6
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    jmentor, you can mark threads solved that you started by using thread tools link at the top of this thread.

Posting Permissions

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