用VC写word文件方法(5)
时间:2012-04-03 来源:office.sc115.com阅读:
次
pItem->Activate (OLEIVERB_SHOW,this); ASSERT_VALID(pItem); m_pSelection = pItem; // set selection to last inserted item pDoc->UpdateAllViews(NULL); // As an arbitrary user interface design, this sets the selection // to the last item inserted. // TODO: reimplement selection as appropriate for your application m_pSelection = pItem; // set selection to last inserted item pDoc->UpdateAllViews(NULL); } CATCH(CException, e) { if (pItem != NULL) { ASSERT_VALID(pItem); pItem->Delete(); } AfxMessageBox(IDP_FAILED_TO_CREATE); } END_CATCH EndWaitCursor(); (7)重载ID—FILE—SAVE, void COfficeView:nFileSave() { // TODO: Add your command handler code here TRY{ LPDISPATCH lpDisp; lpDisp = m_pSelection->GetIDispatch(); Documents docs; _Application app; _Document mydoc; Documents my; mydoc.AttachDispatch (lpDisp,TRUE); app=mydoc.GetApplication ();