在word2003中创建了一个模板文件(*.dot类型),下面的过程是用TWordApplicaton组件初始化Word文件,并与模板文件关联,但是有个错误提示为:Not enough actal parameters,请问该如何改正?
只是在Delphi帮助中查不到该用法,请高手赐教!
程序如下:
procedure TForm1.WordIni(Template:OleVariant);
var
NewTemplate,ItemIndex:OleVariant;
begin
NewTemplate:=False;
ItemIndex:=1;
Try
WordApplication1.Connect;
Except
WordApplication1.Disconnect;
ShowMessage('请安装Office中的Word软件!');
exit;
end;
WordApplication1.Visible:=True;
WordApplication1.Documents.Add(Template,NewTemplate);//参数不匹配错话,该如何改?
WordDocument1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));
end;
只是在Delphi帮助中查不到该用法,请高手赐教!
程序如下:
procedure TForm1.WordIni(Template:OleVariant);
var
NewTemplate,ItemIndex:OleVariant;
begin
NewTemplate:=False;
ItemIndex:=1;
Try
WordApplication1.Connect;
Except
WordApplication1.Disconnect;
ShowMessage('请安装Office中的Word软件!');
exit;
end;
WordApplication1.Visible:=True;
WordApplication1.Documents.Add(Template,NewTemplate);//参数不匹配错话,该如何改?
WordDocument1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));
end;
解决方案 »
- SQL 查询 ACCESS数据库求助,谢过...^_^
- 请问DBChart可以实现横轴为数据库中的一列,纵轴可以显示数据库中的多条吗?即有多条曲线吗?谢谢了!!!!!!!!!!!!
- 我的开发环境:delphi 7, mysql 4.0.18, myodbc 3.51
- 谁会使用CreateProcess,请给个完成例子
- 老大们,有谁能提供 delphi开发的 防火墙 例子吗?谢谢了
- 请问“Name not uniquer in this context”错误提示是怎么回事?
- 关于COM的问题
- 关于decision cube 控件的一个问题!
- !急!急!急如何实现圆的转动效果,以下为我写的VB代码,能用DELPHI代码改写吗
- 如何制作應用程式的自動演示程式????????
- 用过TidTcpServer的高手请进来
- 循环与多线程问题(等待回答.......)
WordApplication1.Documents.Add(Template, NewTemplate,EmptyParam,EmptyParam);
-----------------程序如下--------------------
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Spin, StdCtrls, ExtCtrls, Word2000, OleServer;type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
SpinEdit3: TSpinEdit;
SpinEdit4: TSpinEdit;
SpinEdit5: TSpinEdit;
SpinEdit6: TSpinEdit;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
RadioGroup1: TRadioGroup;
ComboBox1: TComboBox;
BtnPrint: TButton;
OpenDialog1: TOpenDialog;
WordApplication1: TWordApplication;
WordDocument1: TWordDocument;
procedure WordIni(Template:OleVariant);
procedure WriteComment(explans:Array of string);
procedure DeleteComment();
procedure BtnPrintClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DeleteComment;
var
total:integer;
begin
total:=WordDocument1.Comments.Count;
while total<>0 do
begin
WordDocument1.Comments.Item(total).Delete;
total:=WordDocument1.Comments.Count;
end;
end;procedure TForm1.WordIni(Template:OleVariant);
var
NewTemplate,ItemIndex:OleVariant;
begin
NewTemplate:=False;
ItemIndex:=1;
// DocumentType:=wdNewBlankDocument;
// Visible:=True;
Try
WordApplication1.Connect;
Except
WordApplication1.Disconnect;
ShowMessage('请安装Office中的Word软件!');
exit;
end;
WordApplication1.Visible:=True;
WordApplication1.Documents.Add(Template,NewTemplate,EmptyParam,EmptyParam);
WordDocument1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));
end;procedure TForm1.WriteComment(explans:Array of string);
var
i,total:integer;
begin
total:=WordDocument1.Comments.Count;
for i:=0 to total do
WordDocument1.Comments.Item(i).Scope.Text:=explans[i-1];
end;
procedure TForm1.BtnPrintClick(Sender: TObject);
var
re: array of string;
pathname,dotname: string;
begin
OpenDialog1.Options:=[ofAllowMultiSelect,ofFileMustExist];
OpenDialog1.Filter:='Word files (*.dot)|*.dot|All files (*.*)|*.*';
OpenDialog1.FilterIndex:=1;
OpenDialog1.FileName:='memo.dot';
if not OpenDialog1.Execute then
exit;
pathname:=ExtractFilePath(Opendialog1.FileName);
dotname:=ExtractFileName(OpenDialog1.FileName);
if uppercase(copy(dotname,length(dotname)-4+1,4))<>'.DOT' then
begin
showmessage('打开的不是Word格式文件!');
exit;
end;
if uppercase(dotname)<>'MEMO.DOT' then
begin
showmessage('文件名不对!');
exit;
end;
//初始化Word并打开模板memo.dot
WordIni(pathname+dotname);
setlength(re,6);
re[0]:=Trim(Edit1.Text);
re[1]:=RadioGroup1.Items[RadioGroup1.ItemIndex];
re[2]:=SpinEdit1.Text+'年'+SpinEdit2.Text+'月';
re[3]:=SpinEdit3.Text+'年'+SpinEdit4.Text+'月';
re[4]:=SpinEdit5.Text+'年'+SpinEdit6.Text+'月';
re[5]:=ComboBox1.Text;
WriteComment(re);
DeleteComment;end;end.