Click here to Skip to main content
14,300,437 members
Rate this:
Please Sign up or sign in to vote.
See more:
Warning 1
Ambiguity between method 'Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close'. Using method group.

Warning 2
Ambiguity between method 'Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit'. Using method group.

object missing = Missing.Value;
object start1 = 0;

var wordApp = new Microsoft.Office.Interop.Word.Application();

var myDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);

object doNotSaveChanges = WdSaveOptions.wdDoNotSaveChanges;
Range rng = myDoc.Range(ref start1, ref missing);

try
{
    const char newLine = (char)11;
    myDoc.SaveAs(ref fs,
                 ref missing, ref missing, ref missing, ref missing, ref missing,
                 ref missing, ref missing, ref missing, ref missing, ref missing,
                 ref missing,
                 ref missing,
                 ref missing, ref missing, ref missing);
myDoc.Save();

    myDoc.Close(ref doNotSaveChanges, ref missing, ref missing);
    
    wordApp.Quit(ref doNotSaveChanges, ref missing, ref missing);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(myDoc);   
    System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp);
    GC.Collect();
Posted
v2
Comments
Amir Mahfoozi 5-May-13 1:14am
   
http://stackoverflow.com/questions/8303969/how-to-eliminate-warning-about-ambiguity
Sukanta Dey 8-May-13 6:01am
   
Hi,
I guess you have multiple references in the project for Ms-Word.
Can you please remove all you word references and then update with the latest Word refrence.

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100