word2003的文档中包含了5000个人员情况登记表格,如下:能否自动地将每张表中姓名一栏的内容替换表标题处的XX内容,如:在第1张表中,将“张三”字符串替换表标题处的XX。已经试了一星期了,也解决不了。各位TX帮帮忙吧,谢谢了!
解决方案 »
- 线程,太伤人了!!!!!!
- 涨工资了,散分。
- 重庆地区,10000人民币,招程序员一人,详情请进。
- 100分不知够吗?菜鸟用serversocket和clientsocket两个控件做了服务器端和客户端,我的服务器运行之后,我在两台机器上开了两个客户端连
- installshield express for d6的问题?
- 1.533341121E-40在delphi里是什么数!?
- 再一个teechart 的问题
- delphi+sql2000的问题
- 关于随机数的产生
- SendMessage
- 求一个Webservice 操作数据库的例子,增删改,写一个就行。
- 求救! sendmessage 无效!!请大家帮帮我
procedure TForm1.Button1Click(Sender: TObject);
var
tableName:string;
TableCount:integer;
i:integer;
SelectionStart,SelectionEnd:integer;
begin
wordApp:=CreateOleObject('word.application');
wordapp.visible:=true;
wordapp.documents.open('C:\Users\lenovo\Desktop\北京.doc'); TableCount:=wordapp.activeDocument.tables.count;
//获取第一张表名
//表1 xx记录 建议你全部以这种格式('表'+数字+空格+表名+'记录') 现在要做的是获取 tableName=xx;
//建议用一个 循环来查找 表1..表TableCount 获取每张表的tableName //将第一个表中 cell(rol,col) 赋值为 你想要的表格名
for i:=1 to TableCount do
begin
wordapp.selection.find.clearFormatting;
wordapp.selection.find.text:='表'+IntToStr(i);
wordapp.selection.find.wrap:=2; //wdFindStop 到达搜索区域的开始或者结尾时,停止执行查找操作。
wordapp.selection.find.execute;
SelectionStart:=wordapp.selection.end+1;//中间有空格 所以+1; //搜索'记录'
wordapp.selection.find.clearFormatting;
wordapp.selection.find.text:='记录';
wordapp.selection.find.wrap:=2; //wdFindStop 到达搜索区域的开始或者结尾时,停止执行查找操作。
wordapp.selection.find.execute;
SelectionEnd:=wordapp.selection.start; wordapp.selection.start:=SelectionStart;
wordapp.selection.end:=SelectionEnd;
tableName:=wordapp.selection.text;
//将表i中 cell(rol,col) 赋值为 你想要的表格名
wordapp.activeDocument.tables.item(i).cell(1,2).range.delete;
wordapp.activeDocument.tables.item(i).cell(1,2).range.InsertAfter(tableName);
end;
end;应该是可解决你问题了
主要就是word api的操作 http://download.csdn.net/detail/xsl510079027/4200269