+ Reply to Thread
Results 1 to 5 of 5

Open "ANY" excel files in a particular folder

Hybrid View

  1. #1
    Registered User
    Join Date
    09-21-2006
    Posts
    7

    Question Open "ANY" excel files in a particular folder

    -- I am using the following string to open "ANY" excel file in a specific folder..

    Workbooks.Open Filename:= _
    "C:\Excel Data Extract\AnyFile.xls"

    -- Would it be better to use this one?
    "C:\Excel Data Extract\ &''"& '.xls'"

    Any ideas..?? THANKS!!!!

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by Ayansane
    -- I am using the following string to open "ANY" excel file in a specific folder..

    Workbooks.Open Filename:= _
    "C:\Excel Data Extract\AnyFile.xls"

    -- Would it be better to use this one?
    "C:\Excel Data Extract\ &''"& '.xls'"

    Any ideas..?? THANKS!!!!
    Filename = Dir("c:\Excel Data Extract\*.xls", vbNormal)
    MsgBox Filename
    should give you the first file, is that what you need?

    ---

  3. #3
    Registered User
    Join Date
    09-21-2006
    Posts
    7

    Question How Alternate between excel "files/workbooks" without typing exact name of each file

    Hessey,

    Sincere thanks!!

    That was quite helpful. It works now!!

    I am even able to open all the files.

    Would you happen to know how I can alternate between excel "files/workbooks" without having to type in the exact name of every single file as there are hundreds..?

    Thanks in advance.

    Hammy

  4. #4
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  5. #5
    Registered User
    Join Date
    08-18-2006
    Posts
    68
    This sub below will pull all the files from any folder path and name the sheets the file name and imports into a single workbook , Just name a new workbook as IMPORT BOOK.
    Patrick
    Sub IMPORT_ALL_SHEETS()
    Dim WB As Workbook
    Dim TheFile As String
    Dim MyPath As String
    MyPath = 'FOLDER PATH
    ChDir MyPath
    TheFile = Dir("*.xls")
    Do While TheFile <> ""
    Set WB = Workbooks.Open(MyPath & "\" & TheFile)
    ActiveSheet.Name = ActiveWorkbook.Name
    ActiveSheet.Move After:=Workbooks("IMPORT BOOK").Sheets(Sheets.Count)
    TheFile = Dir
    Loop
    End Sub

+ 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