Unable to cast COM object of type 'System.__ComObject' to interface
type 'Microsoft.Office.Core.DocumentProperties'. This operation failed
because the QueryInterface call on the COM component for the interface
with IID '{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the
following error: No such interface supported (Exception from HRESULT:
0x80004002
This exception occurs at the line of code
DocumentProperties docprops =
(Microsoft.Office.Core.DocumentProperties)excelApp.ActiveWorkbook.CustomDocumentProperties;
i use the libraries
using Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;
I want to read the custom properties set on an xls. for this i am
creating an instance of that xls i.e. excelApp...
Can somone please help me out
'Microsoft.Office.Core.DocumentProperties' is a .NET type, and it's
not possible to cast
to _ComObject obsiously. Because DocumentProperties is supposedly
wrapping some
kind of COM object there is probably another way to get this object.
ActiveWorkbook.CustomDocumentProperties is returning a COM object,
not a wrapped one,
following the docs. The CustomDocumentProperties property
indeed exists on another level, but it's from newer libs and not same
(even it's same name,
which may cause the irritation here).
Actually, it has nothing to do with .NET 2.0, it's only that the error
messages come out for
COM/Interop operations are more detailled and no longer silent under
some circumstances.
Finally, this is wrong news group for this questions, at it has
nothing to do with MSHTML.