I am facing a issue while unprotecting the VBA Project of the protected excel.
IntPtr hWnd = FindWindow(null, ES.oXL.VBE.MainWindow.Caption);//Find window
if (hWnd != IntPtr.Zero)
{
bool ret = BringWindowToTop(hWnd); //Bring VBE to top.
}
SendKeys.SendWait("%{F11}%TE" + strPassword + "~~%{F11}");
SendKeys.SendWait("{ENTER}");
SendKeys.SendWait("xyz");
SendKeys.SendWait("{ENTER}");
I Wrote a code like this to unprotect the VBA Project. It works fine when debugging application.
We use com object model. when i applied the same dll in the dll hive, call the function i am getting below error
System.ComponentModel.Win32Exception: Access is denied at System.Windows.Forms.SendKeys.SendInput(Byte[] oldKeyboardState, Queue previousEvents)
Any help on this why its working?