Hi Guys, this code is causing me some difficulty. I am trying to use the code below in Excel 2007 to open all Excel files in a specified folder, but I am getting the run-time error '1004', any ideas on what I am doing wrong? Thanks in advance..
Sub FindOpenFiles()
Dim FSO As Scripting.FileSystemObject, folder As Scripting.folder, file As Scripting.file, wb As Workbook
Dim directory As String
directory = "C:\Users\Documents\VBA\VBA 2\Data"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set folder = FSO.GetFolder(directory)
Set wb = Workbooks.Open(directory)
For Each file In folder.Files
Workbooks.Open wb
Next file
End Sub
Sub FindOpenFiles()
Dim FSO As Scripting.FileSystemObject, folder As Scripting.folder, file As Scripting.file, wb As Workbook
Dim directory As String
directory = "C:\Users\Documents\VBA\VBA 2\Data"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set folder = FSO.GetFolder(directory)
Set wb = Workbooks.Open(directory)
For Each file In folder.Files
Workbooks.Open wb
Next file
End Sub