Using the cancel argument in the Word BeforeSave Event handler

K

kmcmanus

I am trying to display my own custom SaveAs dialog that will allow the user
to save to a database instead of the file system.

I have got the dialog working correctly, but cannot seam to trap when the
user presses cancel. I can detect this from my own saveas dialog but cannot
prevent the user from seeing the standard 'saveas' after canceling my own
dialog.

Below is a simplified version of my code (c#) that produces the error.

I have tried the obvious things, and confirmed that there are no other
addins running.


public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;

if (applicationObject is Word.Application)
{
MessageBox.Show("Word");
((Word.Application)applicationObject).DocumentBeforeSave += new
Microsoft.Office.Interop.Word.ApplicationEvents3_DocumentBeforeSaveEventHandler(Connect_DocumentBeforeSave);
}
}


private void
Connect_DocumentBeforeSave(Microsoft.Office.Interop.Word.Document Doc, ref
bool SaveAsUI, ref bool Cancel)
{
MessageBox.Show("Before Save");
SaveAsUI = false;
Cancel = true;
}
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?a21jbWFudXM=?=,
I have got the dialog working correctly, but cannot seam to trap when the
user presses cancel. I can detect this from my own saveas dialog but cannot
prevent the user from seeing the standard 'saveas' after canceling my own
dialog.
http://support.microsoft.com/default.aspx?scid=kb;en-us;830519

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top