+ Reply to Thread
Results 1 to 5 of 5

Thread: Extract File names...

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    32

    Extract File names...

    Hi All,

    I have a userform with two textbox.....
    The value will be entered based on the file location which the user choose.

    Suppose, for example it can be "
    C:\Documents and Settings\E701152\Desktop\Final_Excel_project\Q2Y580-05.xls
    If this is choosen as the input file Directory,i need to create another directory in the same location like this

    C:\Documents and Settings\E701152\Desktop\Output_Directory\Q2Y580-05.xls
    so the logic is i must extract all the text before the second '\' from the end and then create a directory named Output_directory,then the same filename as Input file name,

    I need to achieve this using VBA code...
    Can someone help me with this.

    Regards
    Ashesh

  2. #2
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,247

    Re: Extract File names...

    Try this

        vecPath = Split(TextBox1.Text, "\")
        ReDim Preserve vecPath(LBound(vecPath) To UBound(vecPath) - 2)
        newPath = Join(vecPath, "\") & "\Output_Directory"
        MkDir newPath

  3. #3
    Registered User
    Join Date
    07-27-2011
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Extract File names...

    Hi Phillips,

    Am getting an object required error ar

    vecPath = Split(TextBox1.Text, "\")

  4. #4
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,247

    Re: Extract File names...

    Maybe your textbox is not called TextBox1.

  5. #5
    Registered User
    Join Date
    07-27-2011
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Extract File names...

    Hi Phillips,

    It worked fine......thanx a lot for ur help.

+ 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.2.0