Is there a way to force Powershell to open a document as read-only and close without saving? Is there a way to force Powershell to open a document as read-only and close without saving? powershell powershell

Is there a way to force Powershell to open a document as read-only and close without saving?


For read only, try this:

$word.Documents.Open("$doc.Fullname", $false, $true)

For closing, try this:

$word.Documents.Close($false)

The MSDN links seem pretty clear about the order these parameters need to appear in and the above worked for me.


Probably you forgot to close the the file in your program. For me defer file.Close() (goLang) fixed it.