I'm not sure what the deal is, but I'm having a problem with this. I've tried all variations of the releascomobject I've found and none of them seem to work. I'm opening an existing file and updating some columns, then print, save, close.
$Excel = New-Object -ComObject Excel.Application
Write-Verbose "Open the $($FileName) spreadsheet"
$Excel.Workbooks.Open($FileName)
Write-Verbose "Open the $($WorkSheetName) worksheet"
$WorkSheet = $Excel.Worksheets.Item($WorkSheetName)
Write-Verbose "Select column $($VolumeIDColumn), the Volume Identification column"
$Range = $WorkSheet.Range($VolumeIDColumn)
Do the updates
$Excel.DisplayAlerts = $false
Write-Verbose "Saving $($FileName)"
$Excel.Save()
Write-Verbose "Closing $($WorkSheetName)"
$Excel.Workbooks.Close()
Write-Verbose "Exit Excel"
$Excel.Application.Quit()
Do the close
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($WorkSheet)
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)
I've also tried FinalReleaseComObject to no avail. Is there a way to determine the Process ID of the instance of my $Excel object and then just call stop-process with that ID? I've grep'd through the object and not found anything that looks like a process id or that matches the process id that is currently running.
For the record, I'm running Windows 7 Enterprise X64 and Office 2010 x86.