Hello guys,
How are you? I was hoping if some one could guide me with the following code extracted from
The code is altered to work automatically each time with Save or SaveAs button. However there are lot of hit and misses. There are times when save is prompted twice. or even when browsing for a location to save the cancel click msgbox shows up.
Could anyone please alter it in ways so it can work for intended purpose?
Thank you.
How are you? I was hoping if some one could guide me with the following code extracted from
Excel VBA - Save As Dialog Window - stop code from continuing if "cancel" is pressed?
I currently use the following code to force the user to save the file as a macro enabled workbook. Application.Dialogs(xlDialogSaveAs).Show , xlOpenXMLWorkbookMacroEnabled The problem is, if the...
stackoverflow.com
The code is altered to work automatically each time with Save or SaveAs button. However there are lot of hit and misses. There are times when save is prompted twice. or even when browsing for a location to save the cancel click msgbox shows up.
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim userResponce As Boolean
On Error Resume Next
userResponce = Application.Dialogs(xlDialogSaveAs).Show("Test name", 52)
On Error GoTo 0
If userResponce = False Then
MsgBox "Cancel clicked"
Exit Sub
Else
MsgBox "You saved file "
End If
End Sub
Could anyone please alter it in ways so it can work for intended purpose?
Thank you.