I've seen many posts on here and elsewhere about using the following code in the ThisWorkbook
Object in order to protect your workbook but still allow macros to run:
Private Sub Workbook_Open()
ActiveWorkbook.Protect UserInterfaceOnly:=True
End Sub
However, the protect function tooltip that pops up only offers three arguments Protect([password], [structure], [windows]). Therefore, when I open the document I get the following error
"Compile Error: Named argument not found"
in regard to UserInterfaceOnly:=True
.
Am I using the wrong protect function, or is there something else I'm missing? I want to allow users to input data into the workbook using forms/macros, but I don't want them to be able to manually change any cells.
It almost seems as if the protect function that I'm running has different arguments than many of the other protect solutions I've found. Could this be a version issue or something else?
Workbook_Open
, however, VBA doesn't seem to be recognizing theUserInterfaceOnly:=True
argument at all. – M. TerryWorkbook_Open
for each sheet I need protected? – M. Terry