tobysmith69
New Member
- Joined
- Aug 28, 2015
- Messages
- 29
Hello all,
I am new to this forum, and a complete and utter beginner at VBA. Using guides from various forums on the internet, I have produced the below sub. It prompts a person to Save As the excel spreadsheet they are in, before calling on another sub which attaches the newly saved spreadsheet to an e-mail. This all works absolutely fine, however when prompted to save the document, if they click Cancel and don't save it, it will still carry out the second sub. I want it to exit the sub and not continue if they haven't saved the document, but I can't for the life of me work out how to do this. Any help gratefully received!
Toby
Sub mcrSave()
'Retrieve file name to use for Save
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")
'If user specified file name, perform Save and display msgbox
If fileSaveName <> False Then
ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=xlNormal
End If
Call EmailOrder
End Sub
I am new to this forum, and a complete and utter beginner at VBA. Using guides from various forums on the internet, I have produced the below sub. It prompts a person to Save As the excel spreadsheet they are in, before calling on another sub which attaches the newly saved spreadsheet to an e-mail. This all works absolutely fine, however when prompted to save the document, if they click Cancel and don't save it, it will still carry out the second sub. I want it to exit the sub and not continue if they haven't saved the document, but I can't for the life of me work out how to do this. Any help gratefully received!
Toby
Sub mcrSave()
'Retrieve file name to use for Save
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")
'If user specified file name, perform Save and display msgbox
If fileSaveName <> False Then
ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=xlNormal
End If
Call EmailOrder
End Sub