Delphi IDE (89)
Windows with Delphi (280)
Visual Basic (1)
Using Formula One ActiveX control - my Excel sheet forgets locked cells (protection)
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:I am using Formula One ActiveX control in Delphi 5. My application generates a complex workbook and locks certain cells. When I export my Excel workbook, the locked cells are forgotten. Protection is enabled, but all cells are unlocked.
Answer:I had the same problem and found that the property EnableProtection does not work as expected.
The documentation says:
EnableProtection sets or returns whether protection is enabled for all selected sheets.
F1Book1.EnableProtection [ = boolean ]
What I found is that the number of places where you temporarily disable the protection must match exactly the number of places where you enable it. The code below will not work if the code executes updateformulas(), as in that case it assigns twice := false and only once := true