Are there Excel settings, that determine that all new Excel files/worksheets are in somehow protected mode?

0

Excel has 'Review' tab with the 'Protect sheet' command, that allows to set password and also set options what should be protected. 'Format cells' is one option to deny the rights to format cells.

I Delphi program, that creates, populates and formats Excel file using OLE approach (https://stackoverflow.com/questions/58285073/delphi-how-to-write-time-string-into-excel-cell-but-preserve-general-numberform is one issue that I solved during the course). All is working fine, but on some computers code 'NumberForm:=...' raises the exception:

Unable to set the numberformat property of the range class

Many threads like https://stackoverflow.com/questions/53418038/run-time-error-1004-unable-to-set-the-numberformat-property-of-range-class and https://stackoverflow.com/questions/58285073/delphi-how-to-write-time-string-into-excel-cell-but-preserve-general-numberform connects this error with the protection feature of the Worksheet, although the error message itself does not refer to the protection (I have tried the protection features and their error messages explicitly mention if the cells are protected), my current hypothesis is that such connection exists.

And now is the main question - why such protection comes into being? I am creating programmatically new Excel file in my program and fully populate it, why the protected regions emerges here? Are there some options of the Excel workstation-wide or user-wide installation that automatically assigns protection for each created Excel file be it created manually or from the program that is invoked by user? Where to see and set such options?

p.s. There are evidence that this error may be due to many formatting operations as well https://support.upslide.net/hc/en-us/articles/115001239843--Unable-to-set-the-NumberFormat-Property-of-the-Range-Class-Issue-with-specific-files- My program aplies ~3000-6000 NumberFormat calls, but this is very low number.

TomR

Posted 2019-10-08T16:58:38.287

Reputation: 121

No answers