Unlocking VBA project in Excel

  • Thread starter Ramkumar Viswanathan
  • Start date
R

Ramkumar Viswanathan

Hello,

I have one password protected vba project in my excel file. I want to unlock
this vba project through C# code. Could anyone help me on this?

I tried the sendKey function of C# but still not able to get through. Here's
the code that I have used:

if(Workbook.VbProject.Protection==
Microsoft.Vbe.Interlop.vbext_ProjectProtection.vbext_pp_locked)
{
Workbook.Activate();
WorkBook.Application.OnKey("%{F11}",Type.Missing);
SendKeys.Send("%F11%TE" + Pwd + "~~");
}

Pwd is the variable containing the password to unlock the vbaproject.

Regards,
Ramo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top