Compare Btn disabled, Office Button dispeared in Word embed in my

L

LeonXYZ

Dear Sir,

I have Word 2007 installed on my computer, The word application is embeded
in my own applcaiotn.
I tried to compare two documents using automation with the following code.
but I got an COleDispatchException
with error message "This command is not available." the exception is caught
when excuting doc.Compare method.
For the word application embeded in my application, it is quite strange that
the Compare button in Reivew Tab of Word Ribbon is disabled/Greyed ! I also
found that the rounded Office Button does not appear on top left corner as it
should !

The Code is somthing like
LPDISPATCH lpDispatch;
COleClientItem *pItem = GetInPlaceActiveItem( dynamic_cast<CWnd
*>(m_MDI));
SCODE sc = pItem->m_lpObject->QueryInterface(IID_IDispatch,
(LPVOID*)&lpDispatch);
// _Document doc = _Document( lpDispatch);
CDocument0_v12 doc = CDocument0_v12 ( lpDispatch);
TRY{
doc.Compare(...)
}
CATCH_ALL(e)
{
TCHAR szCause[255];
CString strFormatted;
e->GetErrorMessage(szCause, 255);
strFormatted += szCause;
AfxMessageBox(strFormatted);
return false;
}
END_CATCH_ALL

I check the Embeded Word instance, to my surprise, I found the Compare
button in Review group[Review->Compare] is disabled/grayed. But most other
buttons in other command groups e.g. Proofing, Comments, Tracking, Changes
are enabled.

*I then try to use CApplication::CompareDocuments command instead as following
CApplication app12 = doc12.get_Application();
CDocuments documents = app12.get_Documents();
CDocument12 doc2nd = documents.Open(vFileName, vConfirmConversions,
vReadOnly, vAddToRecentFiles, vPasswordDocument, vPasswordTemplate, vRevert,
vWritePasswordDocument, vWritePasswordTemplate, vFormat, vEncoding, vVisible,
vOpenConflictDocument, vOpenAndRepair, vDocumentDirection, vNoEncodingDialog);
app12.CompareDocuments(doc12, doc2nd, 1, 1, VARIANT_TRUE, VARIANT_TRUE,
VARIANT_TRUE, VARIANT_TRUE, VARIANT_TRUE, VARIANT_TRUE, VARIANT_TRUE,
VARIANT_TRUE, VARIANT_TRUE, VARIANT_TRUE, _T(""), VARIANT_TRUE);
*but the program throw another Exception with message "The Open method or
property is not available because this document is in another application."

Could you give me some help ?

Thanks a million

Leon_xyz
 
L

LeonXYZ

the shortcut key Ctrl-O to open a file and Ctro-S to save a file is also not
working, but I only concert about the Compare functionality.

Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top