为什么WordApplication1.Documents.Open()编译通不过?(100分)

  • 主题发起人 主题发起人 ccad
  • 开始时间 开始时间
C

ccad

Unregistered / Unconfirmed
GUEST, unregistred user!
在windows2000,office2000,delphi6.0环境下,为什么WordApplication1.Documents.Open
通不过,delphi提示Not enough actual paramenters.

procedure TForm1.Button2Click(Sender: TObject);
var
ItemIndex: OleVariant;
FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert,
WritePasswordDocument, WritePasswordTemplate, Format: OleVariant;
begin
//if not Opendialog1.Execute then Exit;

{Open document}
//FileName := Opendialog1.FileName;
FileName := 'c:/qqq.doc';
ConfirmConversions := False;
ReadOnly := False;
AddToRecentFiles := False;
PasswordDocument := '';
PasswordTemplate := '';
Revert := True;
WritePasswordDocument := '';
WritePasswordTemplate := '';
Format := wdOpenFormatDocument;

WordApplication1.Documents.Open(FileName, ConfirmConversions, ReadOnly,
AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert,WritePasswordDocument,
WritePasswordTemplate, Format);

{Assign WordDocument component}
ItemIndex := 1;
WordDocument1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));

{Turn Spell checking off because it takes a long time if enabled and slows down Winword}
WordApplication1.Options.CheckSpellingAsYouType := False;
WordApplication1.Options.CheckGrammarAsYouType := False;
end;
 
自己看看下面的代码,应该可以的。不行再问。 :)

var
itemindex,install,
ConfirmConversions, ReadOnly1, LinkToSource,
AddToRecentFiles, PasswordDocument, PasswordTemplate,
WritePasswordDocument, WritePasswordTemplate, Revert,
Format, Connection, SQLStatement,
SQLStatement1,pause,name,
FileName, FileFormat, LockComments, Password,
WritePassword, ReadOnlyRecommended,
EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData,
SaveAsAOCELetter,SaveChanges:olevariant;
begin
Install :=False;
itemindex:=1;
WdApp.Connect ;
WdApp.Options.CheckSpellingAsYouType := False;
WdApp.Options.CheckGrammarAsYouType := False;
WordVisible := dtmGroup.WdApp.Visible ;
WdApp.Visible := False ;
WdApp.Documents.AddOld(Template,Install);
WdDoc.ConnectTo(dtmGroup.WdApp.Documents.Item(Itemindex));
WdApp.Visible := True ;
end;
 
我也碰到过这个问题,不只何解!!
楼上兄,你没回答这个问题,你是从另一个角度解决的!!!!
 
WordVisible := dtmGroup.WdApp.Visible ; <----编译出错!

WdDoc.ConnectTo(dtmGroup.WdApp.Documents.Item(Itemindex));<---dtmGroup 编译出错

licby同志,不知道是为什么?

 
WordVisible := True;

你的问题是“参数不足”凑齐就行了
 
可是我感觉参数已经凑齐了呀~!10个参数一个不少~!不知道我说的对不对?
 
word2000应12个参数,看例:
if opendialog1.Execute then
begin
filename := opendialog1.FileName;
confirmconversions := false;
readonly := false;
addtorecentfiles := false;
passworddocument := '';
passwordtemplate := '';
revert := true;
writepassworddocument := '';
writepasswordtemplate := '';
format := wdopenformatdocument;
encoding := '';
visible := true;
wordapplication1.Documents.Open(filename, confirmconversions, readonly,
addtorecentfiles, passworddocument, passwordtemplate, revert,
writepassworddocument, writepasswordtemplate, format, encoding, visible);

end;
 
TO CCAD:
DELPHI6中的WORD2000的OPEN是有12个参数,而实际上WORD2000还有其它形式的OPEN没有
引入。你的问题可以简单地写成:
OleVariant(WordApplication1.Documents).Open('c:/qqq.doc');
省了不少麻烦。
 
或者(use Variants):
WordApplication1.Documents.Open('c:/qqq.doc', EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
 
后退
顶部