cancel save as feature

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Cancel Save As Feature

Cancel Save As Feature

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Hide data in Excel Worksheets

Let's say you have some data in cell 'C5' you would like to hide from the casual viewer.

Click cell 'C5' to select it.

Click the 'Format' menu, select 'Cells'. When the 'Format Cells' dialogue box opens, click the 'Numbers' tab (if necessary), then select 'Custom' from the 'Category' list.

Double-click the 'Type' entry box and type three semi-colons: ";;;"

Click 'OK' to close the dialogue box and accept the new formatting.

The data in cell 'C5' disappears. It's still there and will work in calculations, but it isn't visible.

If you need to check the data, just click the blank cell and the contents appear in the 'Formula bar'.

View all Excel hints and tips


Server loaded in 0.07 secs.