FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour OLE and Excel
Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
OLE and Excel
Posted: Wed Jan 20, 2010 04:26 PM

Hello,
I want to unprotect all a sheeht and onlly protect 2 cells and the activate the protection of the sheet
How to ? Syntax ?
oxls := TOleAuto():New("Excel.Application")
oxls:visible:=.T.
oxls:WorkBooks:Open("c:\test\test.xls")
oBook := oxls:Get( "ActiveWorkBook")
oSheet := oxls:Get( "ActiveSheet" )
and than ??
Select all cells
Desactivate protection
Select on cell
Activate protection of this cell
Activate the protection of the sheet ?

Thanks

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: OLE and Excel
Posted: Thu Jan 21, 2010 05:49 PM

Hi Jack,

To "Lock" or "Unlock" a cell use:
oSheet:Range("A1","A10"):Locked:=.f. (or .t. to lock)

Then to protect the locked cells:
oSheet:Protect( cPassword )

To Unprotect the locked cells:
oSheet:UnProtect( cPassword )

I hope this helps.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: OLE and Excel
Posted: Thu Jan 21, 2010 06:22 PM

Thanks,
it works .

Continue the discussion