mfc利用word库,处理word的问题

bailangtaotian 2012-04-23 10:46:26
我用mfc,导入了word库想对word文档进行操作。选择了一个word文档后,如何实现功能:从文档的第一个字符开始访问,每隔四个字符在访问一个。即1、5、9。。。这样的顺序访问文档。
...全文
155 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
bailangtaotian 2012-04-24
  • 打赏
  • 举报
回复

CRange rng;
rng = wordDoc.get_Content();// wordDoc 是 CDocument0 类型
CFont0 wordFont = rng.get_Font();
float wordSize = wordFont.get_Size();
CFont0 newFont;
newFont.put_Size(wordSize+4);
CRange temptRange;
temptRange.SetRange(0, 10);//选定前10个字符
temptRange.Select();
temptRange.put_Font(LPDISPATCH(newFont));

为什么前10个字符没什么变化?
fishion 2012-04-24
  • 打赏
  • 举报
回复
Range里面的Font方法
bailangtaotian 2012-04-24
  • 打赏
  • 举报
回复
我对office开发不熟悉,Range的函数有GoTo, GoToNext, Next等。msdn库中说明都是英文的,不太理解,而且具体用法没有代码参考,希望再指点的清除些。
bailangtaotian 2012-04-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

word库是什么库,有哪些接口
[/Quote]

#include "CApplication.h"
#include "CDocuments.h"
#include "CDocument0.h"
#include "CRange.h"
#include "CBorders.h"
#include "CFont0.h"
#include "CParagraphFormat.h"
#include "CSelection.h"
#include "CTable0.h"
#include "CTables0.h"
#include "CColumns0.h"
#include "CCell.h"
#include "CWords.h"

之类的
Kaile 2012-04-23
  • 打赏
  • 举报
回复
word库是什么库,有哪些接口
fishion 2012-04-23
  • 打赏
  • 举报
回复
http://hi.baidu.com/rofanliu/blog/item/fab467157bcda0e6c2ce795a.html
参考下这里
思路就是,得到_Document,再调用Range方法,得到Range变量,再调用这个Range里面的方法,如链接上的
bailangtaotian 2012-04-23
  • 打赏
  • 举报
回复
我后续的任务是改变word文档中上述位置字符的大小或者字体,你那种只是把word内容读入到CSting对象中,后续如何处理?
fishion 2012-04-23
  • 打赏
  • 举报
回复
直接读取文档数据
http://blog.sina.com.cn/s/blog_6d2364530100xbuq.html

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧