Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open files in a folder (Excel 2003)

    Hi.

    I am looking to get a list of files in a specific folder, open them one at a time, then go on to the next one, all in a macro.

    Regards

    Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open files in a folder (Excel 2003)

    Code could look like this:

    Sub LoopFolder()
    ' Path including trailing backslash
    Const strPath = "C:Excel"
    Dim strFile As String
    Dim wbk As Workbook
    ' Set strFile to the first file in the folder
    strFile = Dir(strPath & "*.xls")
    ' Loop while there is a file available
    Do While Not strFile = ""
    ' Open workbook
    Set wbk = Workbooks.Open(strPath & strFile)
    ' Process workbook here
    '...
    ' Close workbook
    wbk.Close
    ' And move on to the next file
    strFile = Dir
    Loop
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open files in a folder (Excel 2003)

    Many thanks Hans

Posting Permissions

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