arnie
arnie

Reputation: 239

Open password protected VBA project programmatically

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.

Upvotes: 2

Views: 4507

Answers (2)

Harry Duong
Harry Duong

Reputation: 427

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

Upvotes: 2

arnie
arnie

Reputation: 239

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#?

Upvotes: 1

Related Questions