PRB: Can't Edit Linked Word 95 Documents on Machines w/ Word 97ID: Q187920
|
If you insert a link to a Microsoft Word 95 document into a container application running on a machine with Microsoft Word 97, when you try to open or edit the document, you will receive the following error message:
Failed to launch server application
This problem occurs because the container application thinks the linked document is a Word 97 document, and doesn't realize that it is actually a Word 95 document, which causes the application to throw a COleException (0x80040008 -- Linked object's source class has changed) when it tries to activate the document.
To resolve this problem, it is necessary to handle the COleException thrown by the container. See below for the code necessary to do this.
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
BOOL CRectItem::DoVerb(LONG nVerb, CView* pView, LPMSG lpMsg)
{
ASSERT_VALID(this);
if (pView != NULL)
ASSERT_VALID(pView);
if (lpMsg != NULL)
ASSERT(AfxIsValidAddress(lpMsg, sizeof(MSG), FALSE));
TRY
{
Activate(nVerb, pView, lpMsg);
}
CATCH ( COleException, exception )
{
/*Here's the change. If the linked object's source has changed,
re-bind it to the correct source so Word 97 launches
correctly.*/
if (COleException::Process( exception) == 0x80040008){
IOleLink* fOleLink;
m_lpObject->QueryInterface(IID_IOleLink, (void**)&fOleLink);
IBindCtx* fBinder;
CreateBindCtx(0, &fBinder);
fOleLink->BindToSource(OLELINKBIND_EVENIFCLASSDIFF,
fBinder);
Activate(nVerb, pView, lpMsg);
fOleLink->Release();
fBinder->Release();
exception->Delete ();
}
else
{
// Catch OLE errors and report them as such.
if (!ReportError(exception->m_sc))
AfxMessageBox(AFX_IDP_FAILED_TO_LAUNCH);
exception->Delete ();
return FALSE;
}
}
AND_CATCH_ALL(exception)
{
// Otherwise, show generic error.
AfxMessageBox(AFX_IDP_FAILED_TO_LAUNCH);
exception->Delete ();
return FALSE;
}
END_CATCH_ALL
return TRUE;
}
BOOL DoVerb(LONG nVerb, CView* pView, LPMSG lpMsg);
pItem->DoVerb(OLEIVERB_SHOW, this, NULL);
m_pSelection->DoVerb(iVerb, this, NULL);
DoVerb(OLEIVERB_HIDE, NULL, NULL);
Additional query words: kbDSupport kbDSD kbVC500 kbInterop kbAutomation kbMFC kbOLE
Keywords :
Version : WINDOWS:97; WINNT:5.0
Platform : WINDOWS winnt
Issue type : kbprb
Last Reviewed: July 27, 1999