none
Unlocking VBA project in Excel

    Question

  • 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.

    Wednesday, May 24, 2006 11:19 AM

Answers