Before a Save operation occurs, the BeforeSave event is fired on the ThisDocument object. This event allows you to specify whether the SaveAs UI is displayed or not, and you can cancel the save by setting the Cancel flag. Following code snippet hooks the BeforeSave event, and sets the flags to not show the dialog and to cancel the operation.
private void ThisDocument_Startup(object sender, System.EventArgs e) { this.BeforeSave += new Microsoft.Office.Tools.Word.SaveEventHandler(ThisDocument_BeforeSave); } void ThisDocument_BeforeSave(object sender, Microsoft.Office.Tools.Word.SaveEventArgs e) { e.ShowSaveAsDialog = false; e.Cancel = true; }
This posting is provided "AS IS" with no warranties, and confers no rights. |