Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

onSave Event

Status
Not open for further replies.

mickeyb

Computer
Joined
Jul 25, 2001
Messages
3
Location
GB
Hi

Is there an OnSave event, similar to auto_open() etc ?

Thanks
Mickey
 
Hello Mickey

Excel does not have an OnSave event. However, it does have BeforeSave. BeforeSave occurs BEFORE the workbook is saved.

I quote from the VBA Help:

Syntax:
Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)

SaveAsUi True if the Save As dialog box will be displayed.

Cancel False when the event occurs. If the event procedure sets this argument to True, the workbook isn't saved when the procedure is finished.

EXAMPLE:
This example prompts the user for a yes or no response before saving the workbook.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub

Hope this helps...

Mala
mala_rs_singh@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top