1

As the title states, is this possible? I found some scripts for XLS to XLSX, but not the other way around.

Can this be done with powershell?

Thanks

jes516
  • 145

1 Answers1

4

Setup your variables

$Filepath = 'C:\Users\mad tom vane\Documents\Test1.xlsx'
$Filepath = Get-Item -Path $Filepath
$NewFilepath = Join-Path -path $Filepath.directory.fullname -ChildPath "$($Filepath.basename).xls"

Open Excel up

$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $true #or false

I like to open in Read-Only

$Workbook = $Excel.Workbooks.Open($Filepath.fullname,[Type]::Missing,$true)

Save the workbook as xlExcel8 for an XLS file

$Workbook.SaveAs($NewFilepath,56)

#https://technet.microsoft.com/en-us/library/ff730962.aspx
$Workbook.Close()
$Excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)
Remove-Variable Excel
E.V.I.L.
  • 238