I have code that incorporates business logic for saving documents (Excel 365) to ensure proper naming convention, file locations etc etc as a Sub Workbook_BeforeSave
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True ''Cancels the Save from the button push or Ctrl+S
Application.EnableEvents = False
'' code code code
Application.EnableEvents = True
End Sub
The problem is that if the file is opened as Read-Only (as most will be) Excel will prompt that "the file is Read-Only" (pic a) and go to the Save As screen in the File Ribbon (pic b). The Workbook_BeforeSave
sub won't kick in until the SAVE button is pressed. It also won't move off this screen even after the sub has run.
Is there any way to either:
- Get in front of the Read-Only prompt ... or
- Write some code to move off the Save As screen?
MS Read-Only promt (pic a) Save As Screen (pic b)
Huge thanks in advance!