CoInitialize(NULL);//初始化COM,与最后一行CoUninitialize对应
//CPageSetup pagesetup=doc.get_PageSetup();//页面设置相关,没用到
//CApplication app;
if (!m_app.CreateDispatch(_T("word.application"))) //启动WORD
{
MessageBox(NULL, L"waring", L"CreateDispatch word.application", MB_OK);
return LAUCHWORDERROR;
}
//AfxMessageBox(_T("WORD 已经运行启动啦,你可以用Ctrl+Alt+Del查看"));
//m_app.put_Visible(TRUE); //设置WORD可见。
m_app.put_Visible(TRUE); //设置WORD不可见。
LPDISPATCH tmpDocs = NULL;
tmpDocs = m_app.get_Documents();
if (tmpDocs == NULL)
{
MessageBox(NULL, L"waring", L"tmpSel empty", MB_OK);
return GETDOCUMENTSERROR;
}
COleVariant varOPt(DISP_E_PARAMNOTFOUND, VT_ERROR);
m_docs