操作office一般都是打开文档然后操作,那么如何不打开文档如何取得文档的实例呢,比如我先手动打开一个Word文档,然后程序获得他的实例去操作。类似附加进程这种
可以通过调用组件包openxml开发包来操作word有关的操作
try
{
CString _strbuffer;
CDocumentWindow documentWindow = App.get_ActiveWindow();
CSelection selection = documentWindow.get_Selection();
CTextRange textrange = selection.get_TextRange();
AfxMessageBox(textrange.get_Text());
CFont0 font0 =textrange.get_Font( );
AfxMessageBox(font0.get_Name());
font0.put_Name(_T("楷体"));
font0.put_NameAscii(_T("楷体"));
font0.put_NameFarEast(_T("楷体"));
AfxMessageBox(font0.get_Name());
}
catch (CException* e)
{
AfxMessageBox(_T("请激活当前PPT窗口并选中你要改变的文字!"));
}