ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stop Save as code (https://www.excelbanter.com/excel-programming/403491-stop-save-code.html)

[email protected]

Stop Save as code
 
Hi there guys,

is there a code to stop a user to save as if not all fields are filled
in?

thanks for your help

alex

fujing1003

Stop Save as code
 
On Jan 2, 7:06 am, wrote:
Hi there guys,

is there a code to stop a user to save as if not all fields are filled
in?

thanks for your help

alex


You could use a boolean value to specify whether all the fields are
filled in.
And then only save workbook when the value is true, false to cancel.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Not mbAllFilled Then 'mbAllFilled is used to specify whether all
the fields are filled in.
Cancel = True
MsgBox "Please fill all of fields before you save it!"
End If
End Sub

Jim May

Stop Save as code
 
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = SaveAsUI
End Sub

The above Is the basic "to Cancel any SaveAs attempt" - maybe add as If then
statement to perform the Cancel = SaveAsUI line...

HTH,

Jim


" wrote:

Hi there guys,

is there a code to stop a user to save as if not all fields are filled
in?

thanks for your help

alex


Dave Peterson

Stop Save as code
 
The replies to your other thread include a line like:

Cancel = True

That line stops the Save.

ps. It's better to stick in the same thread when you have followup questions.

wrote:

Hi there guys,

is there a code to stop a user to save as if not all fields are filled
in?

thanks for your help

alex


--

Dave Peterson


All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com