Hey guys, heres a short one :
Globals.ThisAddIn.Application.Inspectors[Inspect].Close(OlInspectorClose.olDiscard);
Throws a Type Mismatch 0x80020005 (DISP_E_TYPEMISMATCH) error.
Close is expecting an OlInspectorClose alright, so I don't know why there is a type mismatch.
EDIT : More code for clarity!
public void Inspectors_Kill(Inspector Inspect)
{
Global.InspectorWrappers[Inspect].CustomTaskPane.Dispose();
Globals.ThisAddIn.Application.Inspectors[Inspect].Close(OlInspectorClose.olDiscard);
Global.InspectorWrappers.Remove(Inspect);
}
[Edit] To state the obvious, why don't you call:
inspect.Close(OlInspectorClose.olDiscard);
Since you already have the inspector?
This is what the C++ looks like (incomplete). The type library information shows that get_Inspectors returns a list of Inspectors:
virtual HRESULT __stdcall get_Inspectors (/*[out,retval]*/ struct _Inspectors * * Inspectors ) = 0;
Imported by:
#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE14\mso.dll" no_namespace
#import "C:\Program Files\Microsoft Office\OFFICE14\msoutl.olb" rename_namespace("Outlook")
Utilizing the smart wrappers, access looks something like this:
_ApplicationPtr app("Outlook.Application");
_InspectorsPtr list = app->GetInspectors();
_InspectorPtr i = list->Item(0);
i->Close(OlInspectorClose::olDiscard);
Notice that I'm passing an integer index to the Item function. In the C# wrapper the interface declaration looks like this:
[DispId(282)]
Inspectors _Application.Inspectors { [DispId(282)] get;
The Inspectors implementation's this indexer looks like:
[DispId(0)]
Inspector this[[MarshalAs(UnmanagedType.Struct), In] object Index] { [DispId(0)] get; }
Notice that the indexer values is declared an object. Its possible that the interop wrapper allows for an Inspector to be passed in, as well as an int. In fact, that would seem the likely scenario given that the indexer would marshal as an int too. Based on your error, I think that may not be the case.
User contributions licensed under CC BY-SA 3.0