L
leafxg
Unregistered / Unconfirmed
GUEST, unregistred user!
说明:D盘根目录存在一个名为123.doc的已加密文件,密码为123。我的目的是想自己来打开加密的123.doc文件,
使用WordApplication1方法打开则没有问题,本程序执行后可以直接打开 (如注释),但是用officecontrol控件
却是弹出一个打开文件的对话框,而并不是直接打开文件。请问这是否有办法解决?如何解决?
ps:我的最终目的是能够使officecontrol控件在打开加密文件时不启动后台的word程序,而是自己判断密码是否正确然后用控件打开。
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
Template, NewTemplate, ItemIndex: OleVariant;
a:OleVariant;
FileName,ConfirmConversions,ReadOnly,AddToRecentFiles,PasswordDocument,
PasswordTemplate,Revert,WritePasswordDocument,WritePasswordTemplate,Format,Encoding,
Visiblelevariant;
begin
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
Wordapplication1.Connect;
// WordApplication1.Visible:=true;
FileName:='d:/123.doc';
ConfirmConversions:=false;
ReadOnly:=false;
AddToRecentFiles:=false;
PasswordDocument:='123';
PasswordTemplate:='';
Revert:=false;
WritePasswordDocument:='';
WritePasswordTemplate:='';
Format:=wdOpenFormatAuto;
Encoding:='';
Visible:=true;
{WordApplication1.Documents.open(FileName,ConfirmConversions,ReadOnly,AddToRecentFiles,PasswordDocument,
PasswordTemplate,Revert,WritePasswordDocument,WritePasswordTemplate,Format,Encoding,Visible); }
//OfficeControl1.CancelLastCommand:=true;
OfficeControl1.CreateNew('Word.Document');
a:=OfficeControl1.ActiveDocument;
a.Application.Documents.open(FileName,ConfirmConversions,ReadOnly,AddToRecentFiles,PasswordDocument,
PasswordTemplate,Revert,WritePasswordDocument,WritePasswordTemplate,Format,Encoding,Visible);
end;
谢谢大家了!
使用WordApplication1方法打开则没有问题,本程序执行后可以直接打开 (如注释),但是用officecontrol控件
却是弹出一个打开文件的对话框,而并不是直接打开文件。请问这是否有办法解决?如何解决?
ps:我的最终目的是能够使officecontrol控件在打开加密文件时不启动后台的word程序,而是自己判断密码是否正确然后用控件打开。
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
Template, NewTemplate, ItemIndex: OleVariant;
a:OleVariant;
FileName,ConfirmConversions,ReadOnly,AddToRecentFiles,PasswordDocument,
PasswordTemplate,Revert,WritePasswordDocument,WritePasswordTemplate,Format,Encoding,
Visiblelevariant;
begin
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
Wordapplication1.Connect;
// WordApplication1.Visible:=true;
FileName:='d:/123.doc';
ConfirmConversions:=false;
ReadOnly:=false;
AddToRecentFiles:=false;
PasswordDocument:='123';
PasswordTemplate:='';
Revert:=false;
WritePasswordDocument:='';
WritePasswordTemplate:='';
Format:=wdOpenFormatAuto;
Encoding:='';
Visible:=true;
{WordApplication1.Documents.open(FileName,ConfirmConversions,ReadOnly,AddToRecentFiles,PasswordDocument,
PasswordTemplate,Revert,WritePasswordDocument,WritePasswordTemplate,Format,Encoding,Visible); }
//OfficeControl1.CancelLastCommand:=true;
OfficeControl1.CreateNew('Word.Document');
a:=OfficeControl1.ActiveDocument;
a.Application.Documents.open(FileName,ConfirmConversions,ReadOnly,AddToRecentFiles,PasswordDocument,
PasswordTemplate,Revert,WritePasswordDocument,WritePasswordTemplate,Format,Encoding,Visible);
end;
谢谢大家了!