1

Case: I have a app written in C#. This app opens VBA Projects (Word). Some VBA Projects are password protected. I use this two libraries:

using Microsoft.Office.Interop.Word;
using Microsoft.Vbe.Interop;

Problem: How can I programmatically open the password protected ones? I'm thinking about popping a window to the user with "Enter password" or something similar.

arnie
  • 189
  • 4
  • 13
  • See [THIS](http://www.siddharthrout.com/2013/04/24/unprotecting-vba-project-password-using-a-password-that-you-know/) There is a code for vb.net. I am sure you can change it to C# – Siddharth Rout Jul 17 '14 at 14:36
  • Also, [this Codeproject Q&A](http://www.codeproject.com/Questions/672736/How-to-password-protect-a-MS-Word-doc-or-docx-file) has C# code for protecting and unprotecting Word documents. I haven't tried it myself, but it's worth a shot. – djikay Jul 18 '14 at 01:11

2 Answers2

2

There is a way to unprotect VBA project for Excel file. So let see if you can apply similar approach for Word VBA project

you can find the solution from Siddharth Rout in the below post.

Unprotect VBProject from VB code

Community
  • 1
  • 1
Harry Duong
  • 407
  • 6
  • 14
0

Unprotecting a "word document" is implemented. But unfortunately there is no method to unprotect a "protected VBA project".

Workarround: With the read only "Protection" field, I check if it's protected and skip this VBA project. After that I show a list with skipped projects to the user.

Unprotect VBA from C# .NET

Set Excel VBA project to be password protected using C#

How to unlock protected vbaproject in a excel file from C#?

arnie
  • 189
  • 4
  • 13