Be careful using the name "Open" for the macro. "Open" is a
reserved word in VBA.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Bob Phillips" wrote in
message ...
Freed,
Here is some code that opens all workbooks in a folder
Sub Open(Folder As String)
Dim sFolder As String
Dim oWB As Workbook
Dim i As Long
With Application.FileSearch
.NewSearch
.LookIn = Folder
.SearchSubFolders = False
.Filename = "*.xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
Set oWB =
Workbooks.Open(Filename:=.FoundFiles(i))
'do your stuff here
oWB.Close SaveChanges:=False
Next i
Else
MsgBox "Folder " & sFolder & " contains no
required files"
End If
End With
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Fred Smith" wrote in message
...
I need to process all the files in a particular folder.
Is there a "For all files in folder Do" construct in VBA?
--
Regards,
Fred
Please reply to newsgroup, not e-mail