Group:  Microsoft Word ยป microsoft.public.word.oleinterop
Thread: Word 2007 & VC++ 2003 OLE App

Word 2007 & VC++ 2003 OLE App
LG 4/5/2007 1:54:05 PM
I am having trouble with Word 2007 and my VC++ 2003 application using
embedded OLE documents. I am using the InlineShapes interface for deleting
inline pictures from Word documents. The problem I am having is when I
delete a Shape from a Word 2007 document, save the document and then close
the document, I get an assertion failure when trying to release the
COleDocObjectItem and winword.exe remains running. The exceptiong is
"0x80010105: The server threw an exception." The next time I try to create a
Word 2007 document using OLE I get the message "Failed to create object.
Make sure the object is entered in the system registry."

This problem only occurs when using Word 2007. Earlier versions of Word
function correctly.

Below is some sample code showing how the Word documents are created...

COleDocObjectItem *pMyDocItem; // initialized elsewhere
CLSID clsid;
CLSIDFromProgID(L"Word.Document", &clsid);
pMyDocItem->CreateNewItem(clsid);


Sample code using Word::_DocumentPtr to remove shapes from a document...

Word::_DocumentPtr pDoc; /* initialized using
COleDocObjectItem::m_lpObject->QueryInterface(IID_IDispatch,...)*/

Word::InlineShapesPtr inlineShapes = pDoc->GetInlineShapes();
Word::InlineShapePtr inlineShape = NULL;

// Delete all inline pictures from the document

long lNumShapes = inlineShapes->GetCount();
for (long loop = 1; loop <= lNumShapes; loop++)
{
inlineShape = inlineShapes->Item(loop);
if (inlineShape->GetType() != Word::wdInlineShapePicture)
continue;


inlineShape->Delete();
loop--;lNumShapes--;
}

pDoc->SaveAs(...); // save the document.

Home | Search | Terms | Imprint
Newsgroups Reader