如何激活另外一个Word文档?(0分)

  • 主题发起人 主题发起人 Jaline
  • 开始时间 开始时间
J

Jaline

Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序中打开多个Word文档,现在要把其他打开的文档关闭,程序如何控制?
我用如下代码:
WordObject:=CreateOLEObject('Word.Application');
WordObject.Visible := True;
...
WordObject.Application.Windows('jbh.doc').Activate;
WordObject.Application.ActiveWindow.close;
出现错误‘windows’非方法,请问用delphi 如何控制呀?
帮帮我,下次给分!
 
var
FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert,
WritePasswordDocument, WritePasswordTemplate, Format: OleVariant;
begin
try
Wordapplication:=CreateOleObject('word.Application');
except
MessageBox(Handle,'初始化Word错误。',
'错误',MB_OK +MB_ICONERROR);
exit;
end;
//*****************
Wordapplication.Visible := True;
WordApplication.Caption := 'Delphi automation';

//*************************
{Open document}
FileName := ExtractFiledir(Application.Exename)+'/xs.doc';
ConfirmConversions := False;
ReadOnly := False;
AddToRecentFiles := False;
PasswordDocument := '';
PasswordTemplate := '';
Revert := True;
WritePasswordDocument := '';
WritePasswordTemplate := '';
Format := wdOpenFormatDocument;

WordApplication.Documents.Open( FileName, ConfirmConversions,
ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate,
Revert, WritePasswordDocument, WritePasswordTemplate, Format );
 
后退
顶部