ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unlocking VBA project in Excel (https://www.excelbanter.com/excel-programming/363379-unlocking-vba-project-excel.html)

Ramkumar Viswanathan

Unlocking VBA project in Excel
 
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.vbe xt_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



All times are GMT +1. The time now is 03:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com