BeforeSave event problem

Prosenjit Banerjee

New Member
Joined
Mar 19, 2002
Messages
19
Hi,

I am in some problem with the "BeforeSave" even of the Workbook. Suppose, I have written a code under the said event. Now, the user chooses the "File->Save As" (or "File->Save" when he is first time saving) option. As soon as he does it the "BeforeSave" event is called up in which I have written some code for saving something (it may be any external files or any registry settings etc.) that SHOULD ONLY BE CALLED IF THE WORKBOOK IS SAVED PROPERLY. But say, the user changes his/her mind and clicks the "Cancel" button of the "File SaveAs" dialog button. But, then what will happen to my event? In that case I will not be revert back my work done in the "BeforeSave" event. So what to do? I want to do something ONLY IF THE WORKBOOK IS SAVED. Please help me.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi
Test for a cancel in the following way:
Here is an Example:

fileSaveName = Application.GetSaveAsFilename(PathToSave, _
fileFilter:="Excel Workbook (*.xls), *.xls")
If fileSaveName <> False Then
ActiveWorkbook.SaveAs fileSaveName
Else
'if false, user cancelled
'Code to deal with cancel
End If

Hope this helps you!
Tom
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,024
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top