我想阻止用户使用与打开它的名称相同的名称保存工作簿,并提供 SaveAs 选项。
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ThisWorkbook.Name = "abc" Then
Cancel = True
SaveAsUI = True
End If
也试过
If ThisWorkbook.Name = "abc" Then SaveAsUI = True
此代码不起作用。另存为对话框不出现。
下次试试
If ThisWorkbook.Name = "abc" Then ThisWorkbook.ReadOnly = True
'Error - can't assign to read only property.