6

Possible Duplicate:
How to eliminate warning about ambiguity?

I'm working with MS Office Word in my application,using the following code:

var wordApplication = new Microsoft.Office.Interop.Word.Application();
var wordDoc = wordApplication.Documents.Open(ref fileName);

//do it.. 

the call of:

wordDoc.Close();
wordApplication.Quit();

give an:

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.

I tried to set requests arguments:

object nullObject = Type.Missing;
wordDoc.Close(ref nullObject, ref nullObject, ref nullObject);
wordApplication.Quit(ref nullObject, ref nullObject, ref nullObject);

but it gives same error. How to fix this? Thanks in advance!

Community
  • 1
  • 1
Jack
  • 16,276
  • 55
  • 159
  • 284

1 Answers1

11

Have you tried this?

((_Application)wordApplication).Quit(ref nullObject,
                                     ref nullObject,
                                     ref nullObject);
Arnold Zokas
  • 8,306
  • 6
  • 50
  • 76