Tuesday, April 17, 2012

C# or VBA -- set Allow "Edit Objects" on protected worksheet from code


// from C#
object n = Type.Missing;
sheet.Protect(n, false, true, true, true, false, false, false, false, false, n, false, false, false, false, n);

// from VBA
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=True
// you can also set the UserInterfaceOnly:=True