Submitted By: Kent Finkle

Opens the existing Excel spreadsheet C:\Scripts\New_users.xls.

PowerShell
Edit|Remove
$comments = @'
Script name: Open-Spreadsheet.ps1
Created on: Tuesday, April 24, 2007
Author: Kent Finkle
Purpose: How can I use Windows Powershell to Open an Excel Spreadsheet?
'@

# -----------------------------------------------------
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject(
[System.__ComObject]$ref) -gt 0)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
# -----------------------------------------------------

$objExcel = new-object -comobject excel.application 
$objExcel.Visible = $True 
$objWorkbook = $objExcel.Workbooks.Open("C:\Scripts\New_users.xls")

$a = Release-Ref($objWorkbook)
$a = Release-Ref($objExcel)