Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

Am using the Interop Word Dll to Generate Word Documents . My problem is that after writing a set of data to the newly created word file i get a save as dialog . How can i suppress/hide this save as dialog . Am using 3.5 Framework & office 2007.

Thanks in advance .
Posted
Comments
tssutha03 8-Dec-11 10:19am    
Please refer this
http://social.microsoft.com/Forums/en-US/Offtopic/thread/3d0d066d-c276-42da-a38a-6e794d9dd9d9

 
Share this answer
 
Comments
Vinodh.B 10-Dec-11 5:49am    
the above link coding i tried and Its failing .
C#
private void DocumentBeforeSave()
{
    this.BeforeSave += new Microsoft.Office.Tools.Word.SaveEventHandler(ThisDocument_BeforeSave);
}

void ThisDocument_BeforeSave(object sender, Microsoft.Office.Tools.Word.SaveEventArgs e)
{
    if (MessageBox.Show("Do you want to save the document?", "BeforeSave",
        MessageBoxButtons.YesNo) == DialogResult.No)
    {
        e.Cancel = true;
    }
}
 
Share this answer
 
If we suppose that your Word application instance is named currentApplication then you should do something like this :
C#
currentApplication.ActiveDocument.Close(SaveChanges:false);


Also you can consider turning off display alerts :
C#
currentApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone


Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900