谁能帮帮忙,我利用word.fileNew已经 创建的模板
现在想要对这个创建好的模板进行添加\删除\修改等功能
该如何进行呢?怎么把这个模板调出来呢?

解决方案 »

  1.   

    unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls,OleCtnrs,ComObj;typeTForm1 = class(TForm)Label1: TLabel;Label2: TLabel;Label3: TLabel;Label4: TLabel;Label5: TLabel;ED_WenHao: TEdit;ED_BiaoTi: TEdit;ED_ShouWenDanWei: TEdit;ED_ZhenWen: TMemo;ED_FaWenDanWei: TEdit;Btn_PrintToWord: TButton;Btn_Quit: TButton;procedure Btn_PrintToWordClick(Sender: TObject);procedure Btn_QuitClick(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}//开始:数据发送到 word事件procedure TForm1.Btn_PrintToWordClick(Sender: TObject);vARVarWord: Variant;// 创建 WORD时所用begintry// 1. 建立 OleObject,连接 word97VarWord:=CreateOleObject('word.basic');// 2. 建立 Word97的新文件VarWord.FileNew;// 3. 设置 Word97的基本状态VarWord.ViewZoom75; //设置显示比例为 75%VarWord.ViewPage; //改为页面显示方式// 4. 将当前数据控件上的信息发送至 Word97// 4.1 发送文号数据VarWord.CenterPara; //居中Varword.font('宋体 '); //设置字体VarWord.FontSize(14); //设置字号varword.insert(#13+#13+ ED_WenHao.Text+#13+#13+#13);// 4.2 发送标题数据VarWord.font('黑体 ');VarWord.Fontsize(16);VarWord.insert( ED_BiaoTi.text+#13);// 4.3 发送收文单位数据VarWord.LeftPara; //左对齐VarWord.Font('宋体 ');VarWord.fontSize(14);VarWord.Insert(#13+ ED_ShouWenDanWei.Text+': '+#13);// 4.5 发送正文数据VarWord.fontSize(14);VarWord.Insert( ED_ZhenWen.Text+#13);// 4.6 发送发文单位数据VarWord.RightPara; //右对齐VarWord.fontSize(14);VarWord.Insert( ED_FaWenDanWei.Text+#13);// 5 最后设置VarWord.StartOfdocument; //到文首VarWord.AppMaxiMize; //设置窗口最大化VarWord.AppShow; //显示应用程序exceptshowmessage('运行 Microsoft Word 失败! ');end; //end of tryend;//end:数据发送到 word事件 //开始:窗口关闭事件procedure TForm1.Btn_QuitClick(Sender: TObject);beginclose;end;//End:窗口关闭事件end.// 这是主程序的尾部 
      

  2.   

    如果创建模板和编辑不在同一个单元
    例如WORD。FILENEW在单元1
    但是我想在单元2 添加呢?
    该怎么办?