index > Visual Studio Tools for Office > How to: Take over Save function?

How to: Take over Save function?

When the user clicks on the save or save-as buttons or closes the document I want to be able to not have word save the document.  I want to be able to take over the whole process of saving the document and forcing the user to not be able to save anywhere else but where I want them to save too.  For example, the user clicks on the save button and the document gets saved to sharepoint using .doc format, I want to not have the savedialog box pop up either.

So the simple process of

1. user clicks save.
2.the document gets saved as .doc - need help finding the save function, will keep looking for it though.
3.the file gets uploaded to sharepoint via webservice. - I dont need help with this.
4.the save dialog box that normally pops up does not show up. - I do need help with this.
5.done

How can I do this and I am using C# with VSTO 2005
Also how do I override the save event ?

If you feel like providing sample code please provide it in C#.

Thank you,

David


Dalik

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.
Mohit Gupta - MSFT
Awesome thank you for that, I had it all but the

e.Cancel = true;

Cheers,

David
Dalik
reply 3

You can use google to search for other answers

 

More Articles

• Another deployment problem
• User-Defined Functions in Excel using VSTO 2005.
• save each page of a word merge as a seperate pdf file.
• Reflection and Excel Toolbars
• Error when add control in the actionsPane
• exporting mdf to excel format
• VSTO and Word menus doesn't merge
• working with different office and word object libraries
• Why VSTO doesnt work on WinXp and it does work on Win2k?
• Assembilies for VSTO files
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Application level addin
• Help! 0x800a16c1 - Object has been deleted
• how to add text in excel file using vb.net
• need help related to VSTO 2005
• VSTO Deployment Models
• Outlook MessageBox hidden when using Wor
• Formatting columns in tables
• inserting page breaks
• Basic setup project for VSTO includes pr
• Intercept events from custom controls
• word document revisions
• Excel/Streamwriter/Kludgy NamedRange acc
• Outlook winforms email template?
• Office.CommandBarButton position
• What "Origin" of Range.EntireR

Hot Articles

• auto open vba form on excel workbook start
• PLEASE READ FIRST: Non-VSTO Question/Iss
• AddIn-Debugging doesn't work anymore?!?!
• Excel Interop from VS2005
• Excel question
• getting data from an excel chart
• Inserting Page numbers into Excel
• Comments color in Word
• VSTO Word Template
• Process informatin from ASP.NET
• After installing VSTO2005 no Office Temp
• Passing Control between Excel and C# code
• Deploying Word Template
• The default behavior to click and open a
• Remove Applications Distributed with Acc

Recommend Articles

• Help with Infopath!!!
• CircleInvalid and clearcirles
• Access Developer Extensions
• Conversion problem
• Delpoying outlook add-in
• Excel Capacities
• Server-side VSTO scalability and licensing
• Shared Add-In
• Deploying research services problem
• VSTO download for MSDN Subscribers
• Adding outlook appointment item to share
• Outlook MailItem
• Outlook add-in error 80010106
• Cutomize File menu in Excel using VSTO 2
• Another deployment problem