近期在做系统,有大量的数据得存入数据库,想用WORD来解决,
但又不知道如何搞定这个问题...
希望知道的朋友给我说说,谢谢了!~
这是要用到office automation
大体就是在classwizard中的automation页加入MSWORD9.OLB
工作区就会引入与Word相关的类
向word发送几个字符大致的过程是这样
 _Application app;
 app.CreateDispatch(_T("Word.Application"));
 app.SetVisible(TRUE);
 Documents docs=app.GetDocuments();
 CComVariant Template(_T("")); //为了简单,没有使用WORD的文档模板
 CComVariant NewTemplate(false),DocumentType(0),Visible;
 docs.Add(&Template,&NewTemplate,&DocumentType,&Visible);
 //Selection表示输入点,即光标闪烁的那个地方
 Selection sel=app.GetSelection();
 //调用函数Selection::TypeText 向WORD发送字符
 sel.TypeText(_T("what can i type?"));
 sel.ReleaseDispatch();  //Selection 不用了,一定要释放
 docs.ReleaseDispatch();  //Documents 也不用了
 CComVariant SaveChanges(false),OriginalFormat,RouteDocument;//false为不保存
 app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
 app.ReleaseDispatch();//释放
如果大批量的导入的话,应该会有更好的方法吧
