I'm call the code when we change mail item in main pane( BY handling
Command-Bar events). I'm able to get Inspector pointer but its WordEditor is
returning NULL. Using the below code to capture Inspector pointer.
Code:
CComPtr< Outlook::Selection>spSelection;
m_pExplorer->get_Selection(&spSelection);
BSTR strname;
if(spSelection)
{
CComPtr< IDispatch > spItem;
CComVariant vCount(1);
spSelection->Item(vCount,&spItem);
if(!spItem)
return;
ATLASSERT(spItem);
CComQIPtr< Outlook::_MailItem> spMailItem(spItem);
ATLASSERT(spMailItem);
fprintf(fileptr,"[WSforOutlookMailItemSearching]->spMailItem::Success\r\n");
fflush(fileptr);
CComQIPtr<Outlook::_Inspector> spInspector;
spMailItem->get_GetInspector(&spInspector)
}
- Kiran. S
wrote:
> Where are you calling that code?
> I've seen, especially in Outlook 2007, that WordEditor is null up until the
> first Inspector.Activate() event. For example it's null in
> Inspectors.NewInspector() because you're only getting a weak object
> reference at that point.
> If there is no Inspector then obviously there can't be a WordEditor object
> since there is no Inspector.
> >
>
> "pasteface method crashing outlook"
> <pastefacemethodcrashingoutlook> wrote in message
> news:176F9A27-950A-4E6B-988E-ECE67B4CDB1B@microsoft.com...
> > Thanks Ken,
> > I tried Word Object Model and tried to capture the WordEditor of an mail
> > item. But inspector->get_WordEditor() is giving null pointer.
> > Code:
> > CComQIPtr<Outlook::_Inspector> spInspector;
> > CComPtr<MSWord::_Document> spWordDoc;
> > CComPtr<MSWord::Selection> spWordSelection;
> > CComPtr<MSWord::_Application> spWordApp;
> > spMailItem->get_GetInspector(&spInspector);
> > CComPtr<Outlook::_Application> spApp;
> > spInspector->get_EditorType(&editType);
> > BSTR str;
> > VARIANT_BOOL vTemp;
> > spInspector->IsWordMail(&vTemp);
> > if(vTemp == VARIANT_TRUE)
> > {
> > spInspector->get_WordEditor((IDispatch**)&spWordDoc);
> > spWordDoc->get_Application(&spWordApp);
> > spWordApp->get_Selection(&spWordSelection);
> > spWordSelection->get_Text(&str);
> > }
> > Please let me know if any issue found.
> > Regards
> > Kiran. S
>