DelphiWord格式.docx

上传人:b****3 文档编号:17843034 上传时间:2022-12-11 格式:DOCX 页数:19 大小:17.83KB
下载 相关 举报
DelphiWord格式.docx_第1页
第1页 / 共19页
DelphiWord格式.docx_第2页
第2页 / 共19页
DelphiWord格式.docx_第3页
第3页 / 共19页
DelphiWord格式.docx_第4页
第4页 / 共19页
DelphiWord格式.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

DelphiWord格式.docx

《DelphiWord格式.docx》由会员分享,可在线阅读,更多相关《DelphiWord格式.docx(19页珍藏版)》请在冰豆网上搜索。

DelphiWord格式.docx

proceduresettableback(backcolor:

toleenum);

//鼠标下移

proceduremovedown(num:

integer=1);

//选择下移

procedureselectdown(num:

//鼠标上移

proceduremoveup();

//鼠标右移

proceduremoveright(num:

//选择右移

procedureselectright(num:

//写字

procedurewritetext(text:

string);

//按样式插入一行记录

//如addline"

备注"

"

正文"

//addline'

kk'

标题1"

procedureaddline(s:

pstyle:

olevariant);

procedurealignline(align:

//插入分页符

procedureinsertpage();

//插入插入页码

procedureinsertpagenum();

//插入日期

procedureinsertdate();

//设置表格一列宽度

proceduresettable(ptable:

columnidx:

width:

integer);

//设置表格一列高度

proceduresettableheight(ptable:

rowidx:

height:

//插入目录

procedureinsertcontents();

//创立书签

procedurecreatebookmark(bookmarkname:

//移动到标签

proceduregotobookmark(bookmarkname:

//粘贴

procedurepaste();

//替换

procedurereplace(source,target:

//保存

proceduresave(filename:

//插入图片

procedureaddpicture(filename:

//移到最后

proceduremoveend();

//合并

procedurecellsmerge();

constructorcreate;

destructordestroy;

override;

end;

//functionmyword:

tmyword;

implementation

//var

// 

fmyword:

{functionmyword:

begin

iffmyword=nilthen

begin

fmyword:

=tmyword.create;

end;

result:

=fmyword;

}

constructortmyword.create();

inheritedcreate;

connectword();

//

proceduretmyword.connectword();

var

b:

boolean;

b:

=false;

if(fword=nil)then

=true

else

try

fdoc.activate;

except

=true;

ifnotbthenexit;

fword:

=twordapplication.create(nil);

fdoc:

=tworddocument.create(nil);

//文档对象

fword.connect;

fword.visible:

destructortmyword.destroy;

//fdoc.saveas('

c:

\1.doc'

);

fdoc.free;

fword.disconnect;

//退出一定退出word,byyl2005.2.2

//fword.quit;

//fword.free;

inheriteddestroy;

proceduretmyword.addreturn();

fword.selection.typeparagraph;

addreturn();

proceduretmyword.setfont(fontname:

boolean

//connectword();

fword.selection.font.name:

=fontname;

fword.selection.font.size:

=fontsize;

iffontboldthen

fword.selection.font.bold:

=wdtoggle;

iffontunderlinethen

fword.selection.font.underline:

=wdunderlinesingle;

setfont(fontname,fontsize,fontbold,fontunderline);

//插入表格

functiontmyword.addtable(col,row:

defaulttable:

olevariant;

defaulttable:

=1;

=fdoc.tables.add(fword.selection.range,row,col,defaulttable,

emptyparam);

showmessage(format('

列%d,行%d'

[col,row]));

addtable(col,row);

//设置背景色

proceduretmyword.settableback(backcolor:

fword.selection.cells.shading.backgroundpatterncolor:

=backcolor;

settableback(backcolor);

//选择下移

proceduretmyword.selectdown(num:

unit_:

count:

extend:

count:

=num;

unit_:

=wdline;

extend:

=wdextend;

fword.selection.movedown(unit_,count,extend);

movedown();

//鼠标下移

proceduretmyword.movedown(num:

//鼠标上移

proceduretmyword.moveup();

fword.selection.moveup(unit_,count,extend);

//选择右移

proceduretmyword.selectright(num:

=wdcharacter;

fword.selection.moveright(unit_,count,extend);

moveright();

//鼠标右移

proceduretmyword.moveright(num:

=wdcell;

//写字

proceduretmyword.writetext(text:

fword.selection.typetext(text);

except 

//防止呼叫失败

writetext(text);

//按样式插入一行记录

//如addline"

//addline'

proceduretmyword.addline(s:

proceduresetstyle(pstyle:

outstyle:

style;

v:

outstyle:

=fword.activedocument.styles.item(pstyle);

v:

=outstyle;

fword.selection.set_style(v);

writetext(s);

//加入一行

setstyle(pstyle);

proceduretmyword.alignline(align:

fword.selection.paragraphformat.alignment:

=align;

//插入分页符

proceduretmyword.insertpage();

_type:

_type:

=7;

fword.selection.insertbreak(_type);

//插入日期

proceduretmyword.insertdate();

datetimeformat:

insertasfield:

insertasfullwidth:

datelanguage:

calendartype:

insertasfield:

insertasfullwidth:

datetimeformat:

='

yyyy'

'

年'

m'

月'

d'

日'

;

datelanguage:

=wdsimplifiedchinese;

calendartype:

=wdcalendarwestern;

fword.selection.insertdatetime(datetimeformat,insertasfield,

insertasfullwidth,datelanguage,calendartype);

insertdate();

//插入页码

proceduretmyword.insertpagenum();

psection:

section;

pagenumberalignment:

firstpage:

psection:

=fword.selection.sections.item

(1);

pagenumberalignment:

//中间

firstpage:

psection.footers.item(wdheaderfooterprimary).pagenumbers.add(pagenumberalignment,firstpage);

//设置表格一列高度

proceduretmyword.settableheight(ptable:

integer);

prow:

row;

prow:

=ptable.rows.item(rowidx);

prow.setheight(height,wdadjustnone);

//设置表格一列宽度

proceduretmyword.settable(ptable:

ptable.columns.item(columnidx).setwidth(width,wdadjustnone);

//插入目录

proceduretmyword.insertcontents();

prange:

range;

useheadingstyles:

upperheadinglevel:

lowerheadinglevel:

usefields:

tableid:

rightalignpagenumbers:

includepagenumbers:

addedstyles:

usehyperlinks:

hidepagenumbersinweb:

withfword.activedocumentdo

prange:

=fword.selection.range;

rightalignpagenumbers:

useheadingstyles:

upperheadinglevel:

lowerheadinglevel:

=3;

includepagenumbers:

usehyperlinks:

hidepagenumbersinweb:

tablesofcontents.add(prange,useheadingstyles,

upperheadinglevel,

lowerheadinglevel,

usefields,

tableid,

rightalignpagenumbers,

includepagenumbers,

addedstyles,usehyperlinks,

hidepagenumbersinweb);

tablesofcontents.item

(1).tableader:

=wdtableaderdots;

tablesofcontents.format:

=wdindexindent;

//创立书签

proceduretmyword.createbookmark(bookmarkname:

withfword.activedocument.bookmarksdo

add(bookmarkname,prange);

defaultsorting:

=wdsortbyname;

showhidden:

//移动到标签

proceduretmyword.gotobookmark(bookmarkname:

what:

which:

name:

what:

=wdgotobookmark;

name:

begin'

fword.selection.goto_(what,

which,

count,

name)

//粘贴

proceduretmyword.paste();

fword.selection.paste;

//替换

proceduretmyword.replace(source,target:

findtext:

pwrap:

replacewith:

replace:

fword.selection.find.clearformatting;

fword.selection.find.replacement.clearformatting;

findtext:

=source;

pwrap:

=wdfindcontinue;

replacewith:

=target;

replace:

=wdreplaceall;

withfword.selection.finddo

{text:

replacement.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 人力资源管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1