Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################
- # PowerShell script to open all Excel files in a folder
- # and re-save them in proper format
- # (c) Dmitry Sotnikov
- ############################
- # create COM object to use Excel
- $objExcel = new-object -comobject excel.application
- $objExcel.Visible = $True
- # open the files to re-save one by one
- dir D:\myfolder\*.xls | ForEach-Object {
- $doc = $objExcel.WorkBooks.Open($_.FullName)
- # Save in new format and with new extension
- # Format codes can be found here:
- # http://msdn.microsoft.com/en-us/library/office/ff198017.aspx
- $doc.SaveAs(“$($_.Directory)\$($_.BaseName).xlsx”,
- [Microsoft.Office.Interop.Excel.XlFileFormat]::xlOpenXMLWorkbook)
- $doc.close()
- }
- $objExcel.Quit()
- $objExcel = $null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement