eAllViews(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::OnFileSave()
{
// 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 ();
/* app.Run ("Macro3");*/
mydoc.Activate ();
BOOL password=mydoc.GetHasPassword ();
mydoc.SetPassword ("love");
password=mydoc.GetHasPassword ();
COleVariant vFalse((short)FALSE);
mydoc.SaveAs (COleVariant("c:\\love.doc"),vFalse,vFalse, COleVariant(""),vFalse,
COleVariant(""),vFalse,vFalse,vFalse,vFalse,vFalse);
}
CATCH(CException, e)
{
}
END_CATCH
}
bulid,click insert object,and edit ,and save.maybe run macro.
自己辛苦了很久加上别人的经验总算做出来。:)