Convert .XLR file to .XLS file

Introduction

This script will Convert Microsoft Works Spreadsheet file XLR to Microsoft Excel file XLS.

Scenarios

This script is to help users to convert .XLR file to .XLS file via PowerShell.

Script

This script contains one advanced function Convert-OSCXLRtoXLS, you can use this script in the following ways:

Step1: Run the script in the Exchange Management Shell, type the one command: Import-Module <Script Path> at the prompt.

For example, type Import-Module C:\Script\ConvertXLRtoXLS.psm1

Here are some code snippets for your references.

PowerShell
Edit|Remove
#Connect Excel
$objExcel = New-Object -ComObject Excel.Application
#Create Save Path 
$NewPath = $i -replace ".xlr",".xls"
#Check if the new path existed
If(Test-Path $NewPath){
    #Remove the File
    Remove-Item -Path $NewPath -Force | Out-Null
}
#Open XLR file in Excel
$objworkbook = $objExcel.Workbooks.Open($i)
#Save as XLS
$objworkbook.SaveAs($NewPath)
#Close Excel
$objworkbook.Close($false)

Examples

Example 1: Convert XLR file "Test1.xlr" to "Test1.xls".
Command: Convert-OSCXLRtoXLS -Path "C:\Test1.xlr"
Screenshot:

Example 2: Convert XLR files "Test1.xlr","Test2.xlr" to XLS format.
Command: C:\PS> Convert-OSCXLRtoXLS -Path "C:\Test1.xlr","C:\Test2.xlr"
Screenshot:



Prerequisite

Microsoft Excel 2010

PowerShell 2.0crosoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.