Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile time warning when using 'Microsoft.Office.Interop.Word._Document.Close'

Anyone know how to solve this warning message?

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.

like image 968
Su Beng Keong Avatar asked Dec 27 '11 02:12

Su Beng Keong


1 Answers

The only way I've managed to resolve the warning is to use an explicit cast:

var doc_close = (Microsoft.Office.Interop.Word._Document) _doc;
doc_close.Close();    

If you already have a using for Microsoft.Office.Interop.Word you can simplify the cast to:

var doc_close = (_Document) _doc;
doc_close.Close();   

or even just

((_Document)_doc).Close();
like image 198
Tod Avatar answered Oct 21 '22 15:10

Tod