Description

This script will convert any Excel document (assuming you have excel installed) to a CSV file in a given directory.

I don’t know who to give credit to, its from a combination of scripters that I no longer remember where I got it from.

Source Code

WorkingDir = "I:\NewBusiness\Import\AMD"
Extension = ".XLS"

Dim fso, myFolder, fileColl, aFile, FileName, SaveName
Dim objExcel,objWorkbook

Set fso = CreateObject("Scripting.FilesystemObject")
Set myFolder = fso.GetFolder(WorkingDir)
Set fileColl = myFolder.Files

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = False
objExcel.DisplayAlerts= False

For Each aFile In fileColl
	ext = Right(aFile.Name,4)
	If UCase(ext) = UCase(extension) Then
		'open excel
		FileName = Left(aFile,InStrRev(aFile,"."))
		Set objWorkbook = objExcel.Workbooks.Open(aFile)
		SaveName = FileName & "csv"
		objWorkbook.SaveAs SaveName, 23
		objWorkbook.Close 
	End If	
Next

Set objWorkbook = Nothing
Set objExcel = Nothing
Set fso = Nothing
Set myFolder = Nothing
Set fileColl = Nothing

3 Spice ups

great script. exactly what I was looking for. thank you.

I was searching for this for long time… Thanks a lot…