Author | Topic: Help translating requested | |
---|---|---|
Bruce Anderson | Help translating requested on Sun, 01 Nov 2009 16:38:06 -0600 Any help or suggestions on translating this Excel generated macro code into XBase++ will be most appreciated. My intent is to leave some spreadsheet columns unlocked so that the user can edit the cells. I have tried everything I can imagine to no good end. Specifically, I would like to learn how to select multiple adjacent columns, how to set "locked" to false (as I can't tell if it is method or an instance var and it seems to looking for a number), and how to formulate the "ActiveSheet.Protect" line. My thanks, Bruce Anderson Columns("B:G").Select Selection.Locked = False Selection.FormulaHidden = False ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowInsertingRows:=True, AllowDeletingRows:=True | |
Bruce Anderson | Re: Help translating requested on Fri, 06 Nov 2009 13:08:46 -0600 Good heavens, this is so simple, I'm surprised even a dolt like you couldn't figure it out! Here's the code: oSheet := oBook:ActiveSheet oSheet:cells:locked := .F. unlock all of the worksheet's cells (by default, they are locked) oRange := oExcel:Range( "B2:C3" ) oRange:value := { {"a", "b"}, {"c", "d" }} oRange:locked := .T. lock only the cells B2:C3 oSheet:protect("Contents:=TRUE") finally, confirm this locked/unlocked worksheet configuration oSheet:EnableSelection := xlUnlockedCells and let the user write to any other cells on the worksheet This will create a worksheet which is editable by the user except for cells B2:C3, which are off limits in all ways. They cannot be edited or deleted. Bruce Anderson |