Hi All, I am using the following code to alert a user that data entry which is required to generate the filename hasn't been made, and when OK is clicked a dialog box appears showing the filename which defaults to '.xls.
I want to add a 'cancel' button to the message box that will stop the close and save process. How can this be done?
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim NameToSaveAs As String
Dim CurrentBookName As String
Dim NameForLabel As String
Dim RangeForLabel As String
Dim FSR As String
Application.EnableEvents = False 'Needed to stop infinite loop on save
If FSR = "" Then
MsgBox "WARNING: There is no FSR No. FSR number is required."
End If
CurrentBookName = ActiveWorkbook.Name
FSR = Range("FSR_NO").Value
NameToSaveAs = FSR & ".xls"
Application.Dialogs(xlDialogSaveAs).Show NameToSaveAs
EndOfSub:
Application.EnableEvents = True
Cancel = True
End Sub
I want to add a 'cancel' button to the message box that will stop the close and save process. How can this be done?