Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycle through a folder of excel files
Does anyone have a way to cycle throught a folder of
files that are on my computer? What I want to do is open the first file in a specific folder, perform a couple of functions, save, close and then open the next file in line to perform the same set of functions. I have a alot of files and don't want to have to open each one seperatly. Chet |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycle through a folder of excel files
Hi Chet
Try this for the files in the folder C:\Data Sub TestFile1() Dim mybook As Workbook Dim FNames As String Dim MyPath As String Dim SaveDriveDir As String SaveDriveDir = CurDir MyPath = "C:\Data" ChDrive MyPath ChDir MyPath FNames = Dir("*.xls") If Len(FNames) = 0 Then MsgBox "No files in the Directory" ChDrive SaveDriveDir ChDir SaveDriveDir Exit Sub End If Application.ScreenUpdating = False Do While FNames < "" Set mybook = Workbooks.Open(FNames) 'your code MsgBox mybook.Name mybook.Close False FNames = Dir() Loop ChDrive SaveDriveDir ChDir SaveDriveDir Application.ScreenUpdating = True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Chet" wrote in message ... Does anyone have a way to cycle throught a folder of files that are on my computer? What I want to do is open the first file in a specific folder, perform a couple of functions, save, close and then open the next file in line to perform the same set of functions. I have a alot of files and don't want to have to open each one seperatly. Chet |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Renaming excel files in a folder | Excel Discussion (Misc queries) | |||
Pulling pdf files from general folder to specific folder | Excel Discussion (Misc queries) | |||
How to let Excel not to save the tmp files in the same folder? | Excel Discussion (Misc queries) | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Discussion (Misc queries) | |||
Open Excel files in a folder | Excel Programming |