Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    311

    Unanswered: im trying to open all files in a folder... 1/2 way there..

    I get an error object expected on the workbook.open line
    the dir exist and the f is a valid file name. Pls help


    Private Function GetFiles(direc As String, ii As Integer) As Variant
    Dim f As String

    f = Dir(direc & "*.xl?", vbNormal)
    Do While f <> ""
    Debug.Print f
    Workbook.Open Filename:="C:\A\" & f
    i = i + 1
    f = Dir
    Loop

    End Function

  2. #2
    Join Date
    Oct 2003
    Posts
    311

    Re: im trying to open all files in a folder... 1/2 way there..

    Originally posted by mikezcg
    I get an error object expected on the workbook.open line
    the dir exist and the f is a valid file name. Pls help


    Private Function GetFiles(direc As String, ii As Integer) As Variant
    Dim f As String

    f = Dir(direc & "*.xl?", vbNormal)
    Do While f <> ""
    Debug.Print f
    Workbook.Open Filename:="C:\A\" & f
    i = i + 1
    f = Dir
    Loop

    End Function
    Workbooks.Open not Workbook.Open

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    FYI - You can use the FileSystemObject for directory/file manipulation.

Posting Permissions

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