a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 編程 > Delphi > 正文

Delphi與Word例1

2019-11-18 18:35:57
字體:
供稿:網(wǎng)友
 

//================== Word_VBA 代碼 ====================//
sub inWord()
  Dim myTable As Table
  Dim myBox, myPict, myShape As Shape
 
  '畫第一個(gè)矩形框
  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"
 
  '個(gè)人信息
  Set myShape = ActiveDocument.Shapes.AddTextbox(Orientation:=1, Left:=351, Top:=90, Width:=126, Height:=99)
  myShape.Line.Visible = msoFalse
  myShape.TextFrame.TextRange.Text = "個(gè)人信息"

  '文本框中添加表格
  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('  沒有選擇統(tǒng)計(jì)文件的存儲(chǔ)位置,不能保存統(tǒng)計(jì)的數(shù)據(jù)!  ','提示框',mb_ok);
     exit;
  end;
  WordApp:=CreateOleObject('Word.Application');
  WordApp.Visible:=True;
  WordDoc:=WordApp.Documents.Add;
  try

  //畫第一個(gè)矩形框
  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';
  //個(gè)人信息  框
  wordShape:=worddoc.Shapes.AddTextbox(Orientation:=1, Left:=351, Top:=90, Width:=126, Height:=99);//.Select;
  wordShape.Line.Visible := false;
  wordShape.TextFrame.TextRange.Text := '個(gè)人信息';
  //文本框中添加表格
  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中根據(jù)分類數(shù)據(jù)生成樹形結(jié)構(gòu)的最優(yōu)方法

下一篇:如何在Delphi應(yīng)用程序中調(diào)用CHM文檔

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
學(xué)習(xí)交流
熱門圖片

新聞熱點(diǎn)

疑難解答

圖片精選

網(wǎng)友關(guān)注

主站蜘蛛池模板: 欧美在线观看在线观看 | 91麻豆精品一二三区在线 | 欧美精品在线一区二区三区 | 91久久精品国产免费一区 | 欧美成人精品在线观看 | 日韩av在线免费电影 | av午夜电影| 91九色视频在线 | 欧美日韩中文字幕 | 成人免费视频一区 | 国产二区三区 | 欧美偷偷操 | 亚洲精品在线播放视频 | 国产精品久久精品 | 成人在线免费av | 精品一区二区在线观看 | 一区二区三区回区在观看免费视频 | 亚洲一区亚洲二区 | 91香蕉| 涩综合 | 久久成人精品 | 美女主播精品视频一二三四 | 一级黄色国产 | 波多野结衣一二三区 | 黄色av网站在线免费观看 | 麻豆av在线播放 | 中文字幕在线观看 | 国产精品一区二区三区在线播放 | 日本精品区 | 日韩激情综合网 | 一级黄色影视 | 久久久高清 | www日本xxx| 久久亚洲网 | 青青免费在线视频 | 亚洲第一国产精品 | 91在线精品一区二区 | 亚州精品成人 | 色.com| 五月婷婷综合网 | 国外成人在线视频网站 |