Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
TIA:
Trying to write code to open all files (one at a time) within specified folder something like: for each file with in folder c:\my documents open do something save close next Thanks, Joel |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Everyone...should have searched first but found prior post with solution.
Joel "Joel" wrote: TIA: Trying to write code to open all files (one at a time) within specified folder something like: for each file with in folder c:\my documents open do something save close next Thanks, Joel |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Joel
This shoud do the trick for you. Sub OpenChange() Dim w As Workbook With Application.FileSearch .NewSearch .LookIn = "C:\My Documents" .SearchSubFolders = False .Filename = ".xls" .FileType = msoFileTypeAllFiles If .Execute() 0 Then For i = 1 To .FoundFiles.Count Workbooks.Open (.FoundFiles(i)) 'Do stuff here. For Each w In Workbooks If w.Name < ThisWorkbook.Name Then w.Close savechanges:=True End If Next w Next i Else MsgBox "There were no files found." End If End With End Sub Regards Marcus Joel wrote: TIA: Trying to write code to open all files (one at a time) within specified folder something like: for each file with in folder c:\my documents open do something save close next Thanks, Joel |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
show most recent files first when opening excel files | Excel Discussion (Misc queries) | |||
Opening Quattro Pro for Windows files (*.WB1 Files) using Excel 20 | Excel Discussion (Misc queries) | |||
run code on opening workbook and apply code to certain sheets | Excel Programming | |||
How can I view files chronologically when opening multiple files | Excel Discussion (Misc queries) | |||
Opening Files with the Same Name | Excel Discussion (Misc queries) |