怎么样用dephi设置word为只读不能对文档内容进行删除与修改(急急) 那位大侠帮帮忙啊了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure SetPassword(const DocFile, OldPass, NewPass: WideString; PassLevel: Integer);var nr,pl,pw:OleVariant; wa:TWordApplication; wd:TWordDocument; wb:OleVariant;begin if not fileexists(DocFile) then exit; wa:=TwordApplication.Create(nil); wa.ConnectTo(CreateOleObject('word.Application') as _Application); try wb:=wa.WordBasic; wb.FileOpen(DocFile); wd:=TWordDocument.Create(nil); try wd.ConnectTo(wa.ActiveDocument); if wd.HasPassword then begin try pw:=OldPass; wd.Unprotect(pw); except end; end; nr:=null; pw:=NewPass; pl:=PassLevel; wd.Protect(pl,nr,pw); wd.Save; finally wd.Close; wa.Quit; wd.Free; end; finally wa.Free; end;end;procedure TForm1.Button2Click(Sender: TObject);beginSetPassword('F:\word\1.doc','','12',1);end; 求助:伪彩映射--类似于Matlab里的bone编码方法 求助Twebbrower的关于word的问题 用dbexpress组件开发的数据库应用程序如何发布??? 我编的Echo程序为什么总是连接主机超时? FastReport 问题求教 菜鸟提问:Form 与 Frame 有何区别? 以下是Delphi帮助的说明,谁能帮忙解释一下? 通过 delphi 将DBF转换成txt 请高手帮忙关于类型不匹配问题? 100分,一个关于ie的简单问题 ??谁用过delphi+oracle开发数据库软件 https(protocol)的用法 怎么更改dns服务器地址
var nr,pl,pw:OleVariant;
wa:TWordApplication;
wd:TWordDocument;
wb:OleVariant;
begin
if not fileexists(DocFile) then exit;
wa:=TwordApplication.Create(nil);
wa.ConnectTo(CreateOleObject('word.Application') as _Application);
try
wb:=wa.WordBasic;
wb.FileOpen(DocFile);
wd:=TWordDocument.Create(nil);
try
wd.ConnectTo(wa.ActiveDocument);
if wd.HasPassword then begin
try
pw:=OldPass;
wd.Unprotect(pw);
except
end;
end;
nr:=null;
pw:=NewPass;
pl:=PassLevel;
wd.Protect(pl,nr,pw);
wd.Save;
finally
wd.Close;
wa.Quit;
wd.Free;
end;
finally
wa.Free;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
SetPassword('F:\word\1.doc','','12',1);
end;