Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Chapel Hill, North Carolina, USA
    Thanked 0 Times in 0 Posts

    Selecting folder and reading file names (2000)

    I need to be able to open three files in a folder, "read" the files names (the names will be different each time) and then combine all the worksheets (tabs) in each file into a single file. I'm confident that I can combine the tabs, but is there an easy way to select the folder/directory and get the file names?


  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Salt Lake City, Utah, USA
    Thanked 5 Times in 5 Posts

    Re: Selecting folder and reading file names (2000)

    <P ID="edit" class=small>(Edited by JohnBF on 12-Nov-04 16:24. Added code.)</P>Is this a one time deal, or are you asking for VBA code? (Since personally I wouldn't code it for a one-time operation.)

    For VBA Code, the Application.GetOpenFileName Method with the Multiselect parameter set to True will return a string array of the user-selected full file names including paths, names which you would then run through a loop and open. An example of using GetOpenFileName with Multiselect is in <!post=this thread,345806>this thread<!/post>, though it gets pretty technical.

    Here's a simpler example:

    Sub OpenMulti()
    Dim varGetMultiFNames() As Variant
    Dim lngC As Long

    varGetMultiFNames = Application.GetOpenFilename("All Excel Files, *.xls", _
    , "Open Excel Files", "Open Excel Files", True)
    For lngC = 1 To UBound(varGetMultiFNames)
    Workbooks.Open Filename:=varGetMultiFNames(lngC)
    Next lngC
    End Sub
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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