Delphi与Word例1
来源:互联网 发布:mac口红所有色号图片 编辑:程序博客网 时间:2024/06/14 06:01
//==================?Word_VBA 代码?====================//
sub inWord()
? Dim myTable As Table
? Dim myBox, myPict, myShape As Shape
?
? '画第一个矩形框
? Set myBox = ActiveDocument.Shapes.AddTextbox(Orientation:=1, Left:=90, Top:=70, Width:=414, Height:=200)
?
? '画一条竖线
? Set myLine = ActiveDocument.Shapes.AddLine(255, 70, 255, 270)
? '画第一幅图
? Set myPict = ActiveDocument.Shapes.AddPicture("D:/test/test/load_jpg1/photo/108259.jpg", _
? LinkToFile:=False, SaveWithDocument:=True, Left:=180, Top:=80, Width:=65, Height:=80)
?
? '画第二幅图
? Set myPict = ActiveDocument.Shapes.AddPicture("D:/test/test/load_jpg1/photo/108259.jpg", _
? LinkToFile:=False, SaveWithDocument:=True, Left:=262, Top:=80, Width:=65, Height:=80)
?
? '姓名
? Set myShape = ActiveDocument.Shapes.AddTextbox(Orientation:=1, Left:=108, Top:=198, Width:=126, Height:=18)
? myShape.Line.Visible = msoFalse
? myShape.TextFrame.TextRange.Text = "姓名:新之助"
? '年龄
? Set myShape = ActiveDocument.Shapes.AddTextbox(Orientation:=1, Left:=108, Top:=225, Width:=126, Height:=18)
? myShape.Line.Visible = msoFalse
? myShape.TextFrame.TextRange.Text = "年龄:12"
?
? '个人信息
? Set myShape = ActiveDocument.Shapes.AddTextbox(Orientation:=1, Left:=351, Top:=90, Width:=126, Height:=99)
? myShape.Line.Visible = msoFalse
? myShape.TextFrame.TextRange.Text = "个人信息"
? '文本框中添加表格
? Set myShape = ActiveDocument.Shapes.AddTextbox(Orientation:=1, Left:=288, Top:=198, Width:=189, Height:=63)
? myShape.Line.Visible = msoFalse
? Set myTable = ActiveDocument.Tables.Add(Range:=myShape.TextFrame.TextRange, NumRows:=3, NumColumns:= _
??????? 2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
? myTable.Cell(1, 1).Range.Text = "体重"
? myTable.Cell(1, 2).Range.Text = "40kg"
? myTable.Cell(2, 1).Range.Text = "身高"
? myTable.Cell(2, 2).Range.Text = "120cm"
? myTable.Cell(3, 1).Range.Text = "坐高"
? myTable.Cell(3, 2).Range.Text = "65cm"
end sub
//==================?Delphi代码?====================//
procedure inDelphi;
var
WordApp,WordDoc,WordTable,wordShape:OleVariant;? //? se:Selection;
filename:string;
begin
? SaveDialog1.InitialDir:=ExtractFilePath(Application.ExeName)+'out_file';
? SaveDialog1.Execute;
? self.Refresh;
? filename:=savedialog1.FileName;
? if length(filename)=0 then
? begin
???? application.MessageBox('? 没有选择统计文件的存储位置,不能保存统计的数据!? ','提示框',mb_ok);
???? exit;
? end;
? WordApp:=CreateOleObject('Word.Application');
? WordApp.Visible:=True;
? WordDoc:=WordApp.Documents.Add;
? try
? //画第一个矩形框
? worddoc.SHAPES.AddTextbox(Orientation:=1,? Left:=90, Top:=70, Width:=414, Height:=200);
? //画一条竖线
? worddoc.Shapes.AddLine(255, 70, 255,270);
? //画第一幅图
? worddoc.SHAPES.addpicture(ExtractFilePath(Application.ExeName)+'photo/108259.jpg',
? LinkToFile:=False, SaveWithDocument:=True, Left:=180, Top:=80, Width:=65, Height:=80);
? //画第二幅图
? worddoc.SHAPES.addpicture(ExtractFilePath(Application.ExeName)+'photo/108259.jpg',
? LinkToFile:=False, SaveWithDocument:=True, Left:=262, Top:=80, Width:=65, Height:=80);
? //画 姓名 框
? wordShape:=worddoc.Shapes.AddTextbox(Orientation:=1, Left:=108, Top:=198, Width:=126, Height:=18);
? wordShape.Line.Visible := false;
? wordShape.TextFrame.TextRange.Text := '姓名:新之助';
? //年龄? 框
? wordShape:=worddoc.Shapes.AddTextbox(Orientation:=1, Left:=108, Top:=225, Width:=126, Height:=18);//.Select;
? wordShape.Line.Visible := false;
? wordShape.TextFrame.TextRange.Text := '年龄:12';
? //个人信息? 框
? wordShape:=worddoc.Shapes.AddTextbox(Orientation:=1, Left:=351, Top:=90, Width:=126, Height:=99);//.Select;
? wordShape.Line.Visible := false;
? wordShape.TextFrame.TextRange.Text := '个人信息';
? //文本框中添加表格
? wordShape:=worddoc.Shapes.AddTextbox(Orientation:=1, Left:=288, Top:=198, Width:=189, Height:=63);//.Select;
? wordShape.Line.Visible := false;
? WordTable := worddoc.Tables.Add(Range:=wordShape.TextFrame.TextRange, NumRows:=3, NumColumns:=2,
???????? DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed);
? WordTable.Cell(1, 1).Range.Text := '体重';
? WordTable.Cell(1, 2).Range.Text := '40kg';
? WordTable.Cell(2, 1).Range.Text := '身高';
? WordTable.Cell(2, 2).Range.Text := '120cm';
? WordTable.Cell(3, 1).Range.Text := '坐高';
? WordTable.Cell(3, 2).Range.Text := '65cm';
? WordDoc.saveas(filename);
? application.MessageBox('? 输出成功!? ','提示框',mb_ok);
? finally
? WordDoc.Saved:=true;
? WordDoc.Close;
? WordApp.Quit;
? end;
end;
- Delphi与Word例1
- Delphi与Word 举例
- Delphi与Word
- Delphi与Word之间的融合技术
- Delphi与Word之间的融合技术
- Delphi与Word之间的融合技术
- Delphi与Word之间的融合技术
- Delphi与Word之间的融合技术
- Delphi中Word与浏览器交互
- Delphi与Word(一)合并Word 表格中单元格
- Delphi与Word(二)取得Word 表格中的数据
- Delphi与Word(三)取得Word文件的数据
- Delphi与Word(一) 合并Word 表格中单元格
- Delphi与Word(二) 取得Word 表格中的数据
- Delphi与Word(三) 取得Word文件的数据
- 大富翁论坛-富翁笔记-Delphi与Word结合技术收藏
- Delphi与Word之间的融合技术(下)zt
- Delphi调用Word
- Delphi与Word(三)取得Word文件的数据
- Delphi与XML
- Delphi与Excel
- (Delphi)Excel的快速导入
- 读取硬盘的物理序列号
- Delphi与Word例1
- Delphi_Excel例子:单元格拷贝粘贴
- Delphi组件与属性编辑器
- INI文件的操作(ASP.NET+C#)
- IIS控制管理(Web虚拟目录的创建及管理)
- 解决.NET(WebApplication)安装部署的不能选择安装路径的问题
- 在Windows下使用GCJ+SWT的实例
- Changes in PHP 5/Zend Engine 2.0
- AMFPHP支持中文的方法(原创,嘿嘿)