I want the user to not be able to save the book with the same name with which it was opened, and offer the SaveAs option.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ThisWorkbook.Name = "abc" Then
Cancel = True
SaveAsUI = True
End If
Also tried
If ThisWorkbook.Name = "abc" Then SaveAsUI = True
This code does not work. The SaveAs dialog box is not displayed.
Next try
If ThisWorkbook.Name = "abc" Then ThisWorkbook.ReadOnly = True
'Error - can't assign to read only property.
source
share