How to check if a word file has a password?
问题 I built a script that converts .doc files to .docx . I have a problem that when the .doc file is password-protected, I can't access it and then the script hangs. I am looking for a way to check if the file has a password before I open it. I using Documents.Open method to open the file. 回答1: If your script hangs on opening the document, the approach outlined in this question might help, only that in PowerShell you'd use a try..catch block instead of On Error Resume Next : $filename = "C:\path