I have a Named cell "CreateHolder" which refers to 'Access Rights'!$F$2 as shown in Name Manager. The referenced worksheet is protected with a password using "UserInterfaceOnly:=True" i.e. user can't change it but VBA can.
I can easily test the value of the named cell, but when I try to update it thru VBA it fails.
My Code:
-----------
If Range("CreateHolder").Value = "" Then ' If no-one else has claimed it, current user can
Range("CreateHolder").Value = Application.UserName
.... etc etc ....
The IF test works fine, however setting the cell value line fails with the following error which causes the whole Workbook_Open() code to stop running:
----------------------------------------------------
Run-time error '1004':
Application-defined or object-defined error
----------------------------------------------------
This is reproducable, and can only be avoided by unprotecting then reprotecting the worksheet with "UserInterfaceOnly:=True" prior to the VBA code above, which of course slows down the Workbook_Open() code where it resides. This is in spite of that code having been run by the previous person who had opened, & saved, the spreadsheet ... the moment I comment out the un/re-protect statements the VBA error above comes back on that line for future opens.
Is this re-setting the protection a requirement with VBA each time the workbook is opened?
I can easily test the value of the named cell, but when I try to update it thru VBA it fails.
My Code:
-----------
If Range("CreateHolder").Value = "" Then ' If no-one else has claimed it, current user can
Range("CreateHolder").Value = Application.UserName
.... etc etc ....
The IF test works fine, however setting the cell value line fails with the following error which causes the whole Workbook_Open() code to stop running:
----------------------------------------------------
Run-time error '1004':
Application-defined or object-defined error
----------------------------------------------------
This is reproducable, and can only be avoided by unprotecting then reprotecting the worksheet with "UserInterfaceOnly:=True" prior to the VBA code above, which of course slows down the Workbook_Open() code where it resides. This is in spite of that code having been run by the previous person who had opened, & saved, the spreadsheet ... the moment I comment out the un/re-protect statements the VBA error above comes back on that line for future opens.
Is this re-setting the protection a requirement with VBA each time the workbook is opened?