2

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.

2
  • See THIS There is a code for vb.net. I am sure you can change it to C# Commented Jul 17, 2014 at 14:36
  • Also, this Codeproject Q&A has C# code for protecting and unprotecting Word documents. I haven't tried it myself, but it's worth a shot. Commented Jul 18, 2014 at 1:11

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.