View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Cycling through all worbooks in a folder



"AA2e72E" wrote:

This code will give you a starting point:

Sub aa()
Set fso =
CreateObject("Scripting.FileSystemObject").GetFold er("c:\OurFiles\")
For Each file In fso.Files
If file.Type = "Microsoft Excel Worksheet" Then
With file
' do what you want with this file
End With
End If
Next
Set fso = Nothing
End Sub

Note: Replace "C:\OURFILES" by your folder; this code does not recurse the
foldre tree if it has one.

"Ben" wrote:

I would like to perform a piece of code on every workbook in a folder and
then close it. What would be the best way please. Thank you