Convert multiple Excel Documents to CSV using Powershell

Looking for a Powershell solution to convert all Excel documents in a specific folder to CSV files.  Also it needs to convert a specific worksheet within all the Excel documents.  All the Excel documents are formatted exactly the same.  I found this solution but it does not convert a specific worksheet (see below).  It only converts the last opened worksheet.

Anyone have this Powershell solution?  I prefer a solution that does not require Excel installed but any solution would be helpful.
Tony EllisIT ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:

Is the same worksheet in each workbook you want to save as a CSV?

Where would the new file be saved and what would it be named?
Tony EllisIT ManagerAuthor Commented:
Yes all the worksheets are named the same in each Excel document.  Just the data is different.  The new file name will be same as the original Excel document (not the worksheet name/label).
NorieAnalyst Assistant Commented:

What's the name of the worksheet you want to save as a CSV?
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Tony EllisIT ManagerAuthor Commented:
NorieAnalyst Assistant Commented:
Try this, change the folder C:\Test\ to the folder you workbooks are in.
$Excel = New-Object -ComObject Excel.Application
$Location = "C:\Test\"     # Path to read files
$SheetName = "Outbound"
$files = Get-ChildItem C:\Test -Filter "*.xls*"

ForEach ($file in $files)
    # Save Sheet1 in each workbook as CSV in same folder
     $WorkBook = $Excel.Workbooks.Open($Location+$file)
     $NewName =$WorkBook.Name.Split(".")[0] + ".csv "

     Write $NewName

     $WorkSheet = $WorkBook.WorkSheets($SheetName)


     $NewBook = $Excel.ActiveWorkbook





Stop-Process -processname EXCEL

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tony EllisIT ManagerAuthor Commented:
Brilliant!!!  It worked perfectly.  Thank you Norie.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.