98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Cancel Save As Feature
Cancel Save As Feature
Resolved · Urgent Priority · Version 2016
Sean has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Cancel Save As Feature
Morning,
I currently have the below code implemented to interrupt the save function in Excel. When someone tries to save it will give them the option to send an email to the owner of the file for a copy, or it will close the application. The issue comes when someone uses the SAVE AS function. When they cancel the userform when using SAVE AS it stops the code and opens the 'browse' window so the user can save before it then does the application.quit request.
is there a way to bypass this window? I've added the prompt for the useform below and the actual userform below that.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
frmSaveWarning.Show
End Sub
//this is the userform below//
Option Explicit
Private Sub cmdAbort_Click()
Unload Me
Application.EnableEvents = False
Application.Quit
End Sub
Private Sub cmdContinue_Click()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim StrSignature As String
Dim strUsername As String
strUsername = Application.UserName
Set OutApp = CreateObject("Outlook.application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "sean.hickman@idealboilers.com"
.CC = ""
.BCC = ""
.Subject = strUsername & "MDS Copy Request"
.Body = strUsername & " has requested they have a copy of the Master Data Sheet, please contact them to discuss"
'walkout from the loading bar
.Display
Application.SendKeys "%s"
.Send
End With
End Sub
RE: Cancel Save As Feature
Hi Sean,
Thank you for the forum question.
Cancel the save event (see below).
You will also need to remove the .Send from the Outlook VBA to get around the security issue.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel=True
frmSaveWarning.Show
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Hide data in Excel WorksheetsLet's say you have some data in cell 'C5' you would like to hide from the casual viewer. |