(5)。在officeView.h添加#include "msword8.h" //如果是Word2000则为#include "msword9.h"
(6)。修改void COfficeView:nInsertObject(),源码如下:
- BeginWaitCursor();
- COfficeCntrItem* pItem = NULL; TRY
- { // Create new item connected to this document.
- COfficeDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc);
- pItem = new COfficeCntrItem(pDoc); ASSERT_VALID(pItem);
- // Initialize the item from the dialog data.
- /* if (!dlg.CreateItem(pItem)) AfxThrowMemoryException(); // any exception will do
- ASSERT_VALID(pItem);*/ CLSID clsid; //
- if(FAILED(::CLSIDFromProgID(L"Word.document",&clsid))) AfxThrowMemoryException();
- if(bOpenStatus) //如果是打开文档
- { if(!pItem->CreateFromFile (sFilename,clsid)) //打开已有文档
- AfxThrowMemoryException(); }
- else //否则新建文档 {
- if(!pItem->CreateNewItem(clsid)) //新建文档 AfxThrowMemoryException();
- } ASSERT_VALID(pItem);