delphi控制word 标题 字符和位置
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ,OleCtnrs,comobj,Word2000, OleServer;// type
TForm1 = class(TForm)
edtTitle: TEdit;
btn1: TButton;
edtDate: TEdit;
edtlength: TEdit;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
procedure FormCreate(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject);
var
s:string;
begin
s:=DateTimeToStr(Now);
edtDate.Text:= Copy(s,,Length(s)-); edtTitle.Text:='一二三四五六七八九十'; edtlength.Text:= '';
end; procedure TForm1.btn1Click(Sender: TObject);
var
FWord :Variant;
FDoc :Variant;
strSQL :string; iLen:integer;//每行字节数
s:string;
iDateLen:Integer;
iTitleLen:integer;
ispace:integer;
i:Integer;
begin
//首先创造对象,如果出现异常就做出提示 //FWord := CreateOleObject('Word.Application'); //Word.Application.11 //2003时
FWord := CreateOleObject('Word.Document.12'); //Word.Application.11 //2003时
//WOrd程序的执行是否可见,值为false时,程序在后台运行。
FWord.Application.Visible := false; //现在打开的Word中,创建一个新的页面,然后在其中键入需要的内容 FDOC :=FWord.Application.Documents.Add;
{对于Word的新页面}
FWord.Application.Selection.Font.Name :='宋体';
// FWord.Application.Selection.Font.Size :=10;
// FWord.Application.Selection.Font.Bold :=0;
{worddoc.PageSetup.LinesPage := 每页行数;
worddoc.PageSetup.CharsLine := 每行字数;} FDOC.PageSetup.CharsLine:= edtlength.Text;
// FWord.Application.Selection.paragraphs.Alignment := wdAlignParagraphLeft;
// FWord.Application.Selection.TypeText(edtdate.text);
FWord.Application.Selection.paragraphs.Alignment := wdAlignParagraphLeft; ilen:= StrToInt(edtlength.Text); //40个汉字
ilen:= *ilen; iDateLen:= Length(edtDate.Text); //
iTitleLen:= Length(edtTitle.Text); // ispace:=(iLen div )-(iTitleLen div )- (iDateLen); s:= edtDate.Text;
for i:= to ispace- do
begin
s:=s+' ';
end;
s:= s+edttitle.Text; FWord.Application.Selection.TypeText(s); // FWord.Application.Selection.TypeText(' 新夏旅游减肥 ');
// FWord.Application.Selection.Typeparagraph;//换行
// FWord.Application.Selection.Typeparagraph;//换行
// FWord.Application.Selection.paragraphs.Alignment := wdAlignParagraphLeft;
// FWord.Application.Selection.Font.Size :=10;
// FWord.Application.Selection.Font.Bold :=0;
// FWord.Application.Selection.TypeText(' 现将我社组团部的');
// FWord.Application.Selection.TypeText(' 新夏旅游减肥 ');
//
// FWord.Application.Selection.Typeparagraph;//换行
// FWord.Application.Selection.Typeparagraph;//换行 //保存文档
//FWord.Application.Caption := '组团计划保存在: '+ExtractFilePath(application.ExeName)+'Reports\xx.doc';
FDOC.SaveAS(ExtractFilePath(Application.ExeName)+'xx.doc'); //E:\myDelphi7\delphi控制word中时间和标题位置 FWord.Application.Quit;
FWord := Unassigned; end; end.
delphi控制word 标题 字符和位置的更多相关文章
- delphi控制 word的几种方法--转
对几种方法的难易程度的判别 a.通过Delphi的控件TOleContainer 将Word嵌入 这是最简单的Ole嵌入,能够直接将Word文档调用,只需要使用ToleContainer.Run就可以 ...
- Delphi读取Word
Delphi读取Word现在关于往Word中写入数据的方法比较多,现在专门开个贴子,希望大家把自己读取Word内容的心得体会说一下,包括读取word文档中,有几个段落,如何读取第几个段落,读取有拼音的 ...
- 使 Word 段落第一行空出两个字符的位置(段落首行缩进)
描述 使 Word 段落第一行左突出两个字符的位置,即段落首行缩进的方式有两种. "视图"选项卡--"显示"组--标尺 "开始"选项卡--& ...
- 控制input输入框光标的位置
一:理解input, textarea元素在标准浏览器下两个属性selectionStart, selectionEnd. selectionStart: 该属性的含义是 选区开始的位置: selec ...
- Delphi 统计Word文档中的字数
急待解决的问题就是如何用delphi实现word中的统计字数 另外想多了解一些关于操作word的相关内容 比如用ole动态创建的和TWordApplication的偏重点在哪里,有什么不同等等…… 用 ...
- 关于.net Microsoft.Office.Interop.Word组建操作word的问题,如何控制word表格单元格内部段落的样式。
控制word表格单元格内部文字样式.我要将数据导出到word当中,对于word表格一个单元格中的一段文字,要设置不同的样式,比如第一行文字作为标题要居中,加粗,第二行为正常的正文. 代码如下 publ ...
- 标题右边10px位置紧跟发布时间
一个ul列表,拥有若干li,内容是新闻标题,标题右边10px位置紧跟发布时间,当标题过长需要控制标题width,需要兼容ie6,不能用max-width h4{font-size:14px;heigh ...
- 用Delphi进行word开发
使用以CreateOleObjects方式调用Word 实际上还是Ole,但是这种方式能够真正做到完全控制Word文件,能够使用Word的所有属性,包括自己编写的VBA宏代码.------------ ...
- 如何使用css和jquery控制文章标题字数?
如何使用css控制文章标题字数? 最佳答案 控制文章标题字数,不是动态网页的专利,如果静态页面使用CSS样式,也可以实现相同的效果! 看这个例子,你们可以复制到记事本保存为HTML文件看效果! < ...
随机推荐
- R 读取excel的方法
1.加载 readxl 包,利用 reade_excel() 函数 install.packages("readxl") library(readxl) data = read_e ...
- 156-PHP strrpos和strripos函数
<?php //定义两个字符串 $str='pasSword'; $position=strrpos($str,'s'); //不区分大小写判断 echo "字母S在{$str}中最后 ...
- 122-PHP类成员函数(三)
<?php class ren{ //定义人类 private function dance(){ //定义private成员方法dance echo '我要跳一支舞.'; } private ...
- opencv目录(转)
github:https://github.com/opencv/opencv OpenCV 3 的源代码文件夹: 3rdparty/: 包含第三方库,如用视频解码用的 ffmpeg.jpg.png. ...
- Bulma CSS - 响应式
Bulma CSS框架教程 Bulma CSS – 简介 Bulma CSS – 开始 Bulma CSS – CSS类 Bulma CSS – 模块化 Bulma CSS – 响应式 Bulma是一 ...
- 5分钟搞懂:JWT(Json Web Token)
https://www.qikegu.com/easy-understanding/892 JWT 基于token的用户认证原理:让用户输入账号和密码,认证通过后获得一个token(令牌),在toke ...
- Windows系统自带选择文件的对话重写和居中处理
class CMyFileDialog: public CFileDialogImpl<CMyFileDialog> { public: CMyFileDialog(BOOL bOpenF ...
- Kubernetes-基于helm安装部署高可用的Redis及其形态探索
首先是一些关于redis的介绍和其在K8S上的安装过程:https://www.kubernetes.org.cn/3974.html 1.1部署形态 通过上述地址的教程,可以完成redis 的安装和 ...
- 关于低成本Sub-1Ghz无线射频方案首选:CMT2110A
对于现在的无线遥控市场竞争力极大,不过是在成本方面和性能方面大家都希望能做到精打细算,目前超低功耗Sub-1Ghz 首选方案是CMT2110/17A 芯片具有超低成本,高性能灵活的单芯片OOK发射器, ...
- 仿flash的文字动画效果
.tips{ font-size: 24px; font-family: sans-serif; font-weight: 600; text-shadow: 1px 1px #ffb700; col ...