在线等待,关于DELPHI与WORD的融合技术之(插如数据到定义的标签处)高手快进。(10分)

  • 主题发起人 hurryman
  • 开始时间
H

hurryman

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var template,newtemplate,documenttype,visable:eek:levariant ;
begin
template:='d:/doc1.dot' ;
newtemplate:=true ;
documenttype:=null ;
visable:=true ;
try
wordapplication1.Connect ;
except
messagedlg('maybe you not setup word!',mterror,[mbok],0);
abort ;
end;
wordapplication1.Visible :=true ;
wordapplication1.Caption :='control word with delphi';
newtemplate:=true ;
wordapplication1.Documents.Add(template,newtemplate,documenttype,visable);
***********************************************************
worddocument1.Bookmarks.Add('11111',documenttype);
*************************************************************
在这个书签的位置送数据进去,我定义了10个书签,如何送,上面这句有问题,
我不会使用书签,大家帮我看看。
end;
 
100分我告诉你。
 
这个问题怎么解决。
 
我很急,查MSDN没查到,大家帮我看看这个问题如何解决。
 
也想知道
 
先在Word中录制宏,
然后自Delphi中实现,
理论上只要Word中能作到的,
程序都可以实现
 
wordDoc:WordDocument;
WordDoc.Bookmarks.item('书签名').Range.Text := 替换值;
 
procedure TForm1.Button1Click(Sender: TObject);
var template,newtemplate,documenttype,visable:eek:levariant ;
i:integer;
begin
template:='d:/doc1.dot' ;
newtemplate:=true ;
documenttype:=null ;
visable:=true ;
try
wordapplication1.Connect ;
except
messagedlg('maybe you not setup word!',mterror,[mbok],0);
abort ;
end;
wordapplication1.Visible :=true ;
wordapplication1.Caption :='control word with delphi';
wordapplication1.Documents.Add(template,newtemplate,documenttype,visable);
for i:=1 to worddocument1.Bookmarks.Count do
begin
worddocument1.Bookmarks.Item('bookmark01').rang.text :='sdfs';
// worddocument1.bookmarks.item('bookmark01').select ;
// worddocument1.selection.text :='aaaaaaa';
worddocumnet1.Activate;
end;
end;
这么用书签会提示出错:
types of actual and formal var parameters must be identical

 
还想想大家请教的是,如何在模版里添加的是书签,我怀疑自己这个添加方法是不是
存在问题。
插入--》书签—》输入书签名称-》添加
最后保存为模版。
 
我接触这方面不久,希望大家帮我。
 
很奇怪的用法,wordDocument1怎么放入循环中?
这是其一,另外,错误信息的意思出在Documents.add这里。
你定义的documenttype赋予一个NULL值,对于COM,它可认不了
这个东西,如果想用空值,请使用EmptyParam
 
procedure TForm1.Button1Click(Sender: TObject);
var template,newtemplate,documenttype,visable:eek:levariant ;
begin
template:='d:/doc1.dot' ;
newtemplate:=EmptyParam ;
documenttype:=EmptyParam;
visable:=true ;
try
wordapplication1.Connect ;
except
messagedlg('maybe you not setup word!',mterror,[mbok],0);
abort ;
end;
wordapplication1.Visible :=true ;
wordapplication1.Caption :='control word with delphi';
wordapplication1.Documents.Add(template,newtemplate,documenttype,visable);
==============================================================
====worddocument1.Bookmarks.Item('bookmark01').select ;=======
==============================================================
worddocument1.selection.text :='aaaaaaa';
worddocumnet1.Activate;
end;
上面的框里出错,始终停在那里,不明白。
错误提示:
types of actual and formal var parameters must be identical
 
顶部