ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automation in excel (https://www.excelbanter.com/excel-programming/397750-automation-excel.html)

SnOOpss

Automation in excel
 

Hello !
I work on VS 2005 and I use this sample to my application
http://support.microsoft.com/kb/q216686/ . I use automation to control excel
WITHOUT mfc and WITHOUT #import only pure api win32.
It's work perfectly but I have a big problem : The worksheet is protect in
excel

code VBA

Sheets(1).Protect Password:="XXXXXX", _
UserInterFaceOnly:=True


Someone know the params to invoke to unprotect the sheet or to execute a
macro by automation ?
I try this without chance.


bool MyExcel::SetProtect(bool b) {
VARIANT x;
x.vt = VT_I4;
x.lVal = b;
x.bstrVal=SysAllocString(L"XXXXXXXX");
//AutoWrap(DISPATCH_METHOD, NULL, pdispWorksheet, L"Protect", 0);
AutoWrap(DISPATCH_PROPERTYPUT, NULL, pdispWorksheet, L"Protect", 1, x);
return true;
}

I have the message, member unknow.



All times are GMT +1. The time now is 07:19 PM.

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