|
发表于 2008-5-13 11:18:54
|
显示全部楼层
uses
Business.System, Business.Model, Business.Forms, Business.Data
,GJL,
DocOffice ,DocLib ,
Business.System.SysUtils
,Business.Forms.Forms ,Business.Forms.Controls, sictrpt;
===============
FWordOleExtend: TWordOleExtend;
rootPath : String;
selWordName ,ContractID: String;
============
{打开WORD 合同}
procedure TWBSCBD.EditModle();
Var
selectedModel ,selectedDoc : String;
newWordName ,infoType : String;
isSelectModel, isSelectDoc : boolean;
atts : TStrings;
lBizURL : TBizURL;
datas : Vector;
begin
WebB_Word.Navigate('about:blank');
selectedModel := DataSetBrokerHTMB.DataSet.FieldByName('MDName').AsString;
infoType := CB_InfoType.Text.Trim();
lBizURL := TBizURL.Create;
selectedDoc := DataSetBrokerHT.DataSet.FieldByName('ContractName').AsString;
ContractID := DataSetBrokerHT.DataSet.FieldByName('ContractID').AsString;
lBizURL.URL := htTableURL;
selWordName := selectedDoc;
//JSDialogs.ShowMsg(selWordName,'提示:');
//word Operater
if FWordOleExtend <> nil then
TUnStructureDocUtils.DestroyWordOleExtend(FWordOleExtend);
FWordOleExtend := TUnStructureDocUtils.CreateWordOleExtend('');
//create file directory
if not DirectoryExists(rootPath) then
begin
if not DirectoryExists(rootPath ) then
CreateDir(rootPath ) ;
end;
if trim(selectedModel) = '' then
isSelectModel := false
else
isSelectModel := True;
if trim(selectedDoc) = '' then
isSelectDoc := false
else
isSelectDoc := True;
if isSelectModel and isSelectDoc then
begin
newWordName := rootPath + '\' + selectedDoc +'.doc';
if FileExists(newWordName) then
//delete word
TUnStructureDocUtils.DelExistFile(newWordName);
//download word
DataSetBrokerHTMB.DataSet.Locate('MDName' ,[selectedModel], []);
TBlobField(DataSetBrokerHTMB.DataSet.FieldByName('Content')).SaveToFile(newWordName);
//给宏赋值
atts := TStringList.Create;
//lBizURL := TBizURL.Create;
//lBizURL.URL := cTableURL;
atts := getAttName(lBizURL ,infoType);
TUnStructureDocUtils.OpenWordDoc(FWordOleExtend, newWordName, False);
datas := getAttValue(atts , selectedDoc, FWordOleExtend,ContractID);
TUnStructureDocUtils.ShowWordFieldCodes(FWordOleExtend, False);
TUnStructureDocUtils.SaveWordDoc(FWordOleExtend);
TUnStructureDocUtils.CloseWordDoc(FWordOleExtend);
TUnStructureDocUtils.DestroyWordOleExtend(FWordOleExtend);
atts.Clear;
//open word
//TUnStructureDocUtils.OpenWordDoc(FWordOleExtend, newWordName, True); //way 1
WebB_Word.Navigate(newWordName); //way 2
//TUnStructureDocUtils.ShowWordFieldCodes(FWordOleExtend, True);
end
else
JSDialogs.ShowMsg('请选择合同模版名称和选择合同名称!','提示:');
ButtonClose.Enabled := True;
ButtonUpcase.Enabled := False;
end; |
|