procedure TfmSaleBooking.DoPrintExecute(Sender: TObject);
var
aSelection,
aDocument : Variant;
Replace,
FileName : OleVariant;
procedure FReplace(FindText : String;
ReplaceWith : String);
begin
aSelection.Find.ClearFormatting;
aSelection.Find.Replacement.ClearFormatting;
aSelection.Find.Text := FindText;
aSelection.Find.Replacement.Text := ReplaceWith;
aSelection.Find.Forward := True;
aSelection.Find.Wrap := wdFindContinue;
aSelection.Find.Format := False;
aSelection.Find.MatchCase := False;
aSelection.Find.MatchWholeWord := False;
aSelection.Find.MatchByte := True;
aSelection.Find.MatchWildcards := False;
aSelection.Find.MatchSoundsLike := False;
aSelection.Find.MatchAllWordForms := False;
replace := wdReplaceAll;
aSelection.Find.Execute(EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, replace, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
end;
begin
if qryData.Active and not qryData.IsEmpty then
with WordAppdo
begin
Connect;
Visible := False;
FileName := Global.ExePath + '购房订单.doc';
aDocument :=do
cuments.OpenOld(FileName, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
aSelection := Selection;
FReplace('<甲方>', qryData.FieldByName('company').AsString);
FReplace('<乙方>', CustName);
FReplace('<单元>', qryData.FieldByName('lk_village').AsString
+ qryData.FieldByName('lk_building').AsString
+ qryData.FieldByName('room_number').AsString);
FReplace('<建筑面积>', qryData.FieldByName('area').AsString);
FReplace('<单价>', qryData.FieldByName('unit_price').AsString);
FReplace('<总价>', qryData.FieldByName('cal_TotalPrice').AsString);
FReplace('<付款方式>', qryData.FieldByName('lk_pay_mode').AsString);
FReplace('<甲方电话>', qryData.FieldByName('phone').AsString);
FReplace('<甲方地址>', qryData.FieldByName('addr').AsString);
FReplace('<甲方邮编>', qryData.FieldByName('post_code').AsString);
FReplace('<乙方联系电话>', ContactPhone);
FReplace('<乙方地址>', Address);
FReplace('<乙方邮编>', PostCode);
FReplace('<乙方身份证号>', IdCode);
FileName := Global.ExePath + Global.NewGUID + '.doc';
aDocument.SaveAs(FileName, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
Visible := True;
Disconnect;
end;
end;