In our company we are using Windows application to generate Word (2010) documents. Sometimes the document is not properly closed, so another application (yes, they still cal
You need to attach to the running Word instance as described here, and then close the document:
$wd = [Runtime.Interopservices.Marshal]::GetActiveObject('Word.Application')
$wd.Documents | ? { $_.Name -eq 'some.docx' } | % {
$_.Saved = $true
$_.Close()
}
This must be run in the context of the user who started the application, and it will only attach to the instance started first (usually there's only one instance running anyway). You'd need to quit that instance first before you can attach to the instance started second.