View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
SnOOpss SnOOpss is offline
external usenet poster
 
Posts: 1
Default 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.