Thanks,
Larry
Sub ProcessXLSFilesInDirectory()
Dim aFiles() As String, iFile As Integer
Dim stFile As String, vFile As Variant
Dim stDirectory As String
Dim stCSV As String
Dim stCSVDir As String
' first build an array of the files and then process them
' this is because you may upset the Dir function if you save a file
stDirectory = "D:\TEMP\" ' name of directory to look in
stCSVDir = "D:\CSV\" ' where to put the CSV files
' use Dir function to find XLS files in Directory
stFile = Dir(stDirectory & "*.XLS")
If stFile = "" Then Exit Sub ' no files to process
Do While stFile <> ""
' add to array of files
iFile = iFile + 1
' add one element to the array
ReDim Preserve aFiles(1 To iFile)
aFiles(iFile) = stFile
stFile = Dir() ' gets next file
Loop
' now process the files
Application.DisplayAlerts = False ' no messages about overwriting
For Each vFile In aFiles
Workbooks.Open stDirectory & vFile
stCSV = Application.Substitute(vFile, ".xls", ".csv")
Workbooks(vFile).SaveAs stCSVDir & stCSV, Fileformat:=xlCSV
Workbooks(vFile).Close saveChanges:=False
Next vFile
End Sub
--
Bill Manville
Microsoft Excel MVP
Oxford, England
Larry Garner <larry...@mindspring.com> wrote in message
news:7osoer$t46$1...@nntp3.atl.mindspring.net...