I have a Word document that is password protected. I know the password, and I want to use this document to open it. I tried to find information on how to programmatically set a password when opening a document. Found the Password property of the Document class object that sets the password when opening a document (the Document interface description is https://msdn.microsoft.com/ru-ru/library/microsoft.office.tools.word.document.aspx ), but when opening The "Type mismatch" error occurs.
Small and sufficient for example code:

static void Main(string[] args) { Application app = new Application(); Document doc = new Document(); doc.Password = "123"; app.Documents.Add(doc); app.Documents.Open(@"C:\Users\Олег\Desktop\Проекты C#\Тест.docx"); Console.ReadKey(); } 

    0