I have a script that will open an existing xlsm document and save it back once things are complete. The script works well except that when the file closes an excel.exe process still runs in the background. If I run the script a few times I will have 1 excel.exe process for each. Is there something that I can add to the script to eliminate or prevent the continued process from existing?
I do not want a brute force method though.
thanks in advanced.
$a = New-Object -comobject Excel.Application
$a.visible = $true
$path = "C:\powershell\source\"
$file1 = get-content "c:\powershell\source\sourcefile.txt"
$pathFile = $Path + $file1
$b = $a.Workbooks.Open($pathfile)
$c = $b.Worksheets.Item(7)
$fs = New-Object -ComObject scripting.filesystemobject
$absolutepath = $fs.GetAbsolutePathName("c:\powershell\Results\" + $file1)
$a.application.displayalerts = $false