Can a variable be passed from the app to the rtf file ?
Thanks
Can a variable be passed from the app to the rtf file ?
Thanks
Hi,
Check pout the RTFVaraiables collection. You can store any string variable and also streams.
Julian
Is it then possible, instead of linking to data for individual letters, pass the address and other detail, i.e today's date to the letter instead ?
Hi,
please read about 'mailmerge' in the manual. I think this is what you actually need.
Julian
Julian
I have mailmerge working at the moment, however the letters in our app
can come from many different tables and some data is not always available via sql, thus I need to either add extra fields calculated before the mailmerge is performed or better still, because I am only creating one letter at a time, pass the address and other info as variables.
Thanks
Andy
I can't find rtfvariables in the pdf manual, do you have more information ?
Thanks
Andy
I have some info on newsgroup search.
WPRichText1.RTFVariables.Items[0].Text etc.
Once I fill the variables how do I insert into my document ?
Is there an example ?
One of the other reasons to use this method is compressing the address to remove blank lines, I can pass the address a variable.
Thanks
Andy
These variables are like the document variables in Word - and compatible to those.
To create mailmerge fields use InputField
Julian
The same as Word, what do you mean ?
Do i use inputfield for both mailmerge and rtfvariables ?
What do I actually type into my wptools rtf template ?
e.g {currentdate} ??
Andy
Please do not confuse this:
RTFVaraiables is the same as the document variables in Word
Mailmerge fields are created with InputField and filled in te OnMailMwergeGetText event - from any source you want
CurrDate etc are TextFieldObjects. They are calculated by the editor and usually created with InputTextField
Sorry, I can't be explaining myself very well. here is the problem.
I have one template called main.rtf.
I want to produce one letter at a time, from one of 4 different tables, but only using 1 template. The sql and code for it is below :
In the table CONTRCTORS, the field CLAIM_NO does not exist so I want to pass it as a variable.
Thanks
if (dmClaim.AdsFreeLett.FieldByName('LETTTYPE').ASString = 'Insurer') or (dmClaim.AdsFreeLett.FieldByName('LETTTYPE').ASString = 'Policyholder') then begin
WhereStatment := 'select CLAMPH as NAME, PH_ADD1 as ADD1, PH_ADD2 as ADD2, PH_ADD3 as ADD3,PH_ADD4 as ADD4,PH_ADD5 as ADD5, CLAMNO, INS_REF, PH_PC as POSTCODE from insclaim WHERE insclaim.CLAMNO ='''+ dmClaim.AdsInsClaim.FieldByName('CLAMNO').ASString +'''';
//showmessage(WhereStatment) ;
end;
if (dmClaim.AdsFreeLett.FieldByName('LETTTYPE').ASString = 'Contractor') then
begin
fmClaim_Main.AdsSettings1.Showdeleted := false ;
WhereStatment := 'select NAM as NAME, ADD1, ADD2, ADD3,ADD4,ADD5, POSC as POSTCODE from CONTRCTORS WHERE CONTRCTORS.COD ='''+ dmClaim.AdsWorks.FieldByName('ACCOUNT').ASString +'''';
dmClaim.AdsWorks.Close ; //opened in FreeLettedit
end;
if (dmClaim.AdsFreeLett.FieldByName('LETTTYPE').ASString = 'Share') then begin
WhereStatment := 'select NAM as NAME, ADD1, ADD2, ADD3, ADD4, ADD5, CLAMNO, SHR_PC AS POSTCODE, 0 as INS_REF from claim_share WHERE claim_share.clamno ='''+ dmClaim.AdsFreeLett.FieldByName('CLAIMNO').ASString +''' AND claim_share.NAM ='''+ dmClaim.AdsClaim_Share.FieldByName('NAM').ASString+''''
end;
if (dmClaim.AdsFreeLett.FieldByName('LETTTYPE').ASString = 'Share Insurer') then begin
WhereStatment := 'select INSNAM as NAME, INSADD1, INSADD2, INSADD3, INSADD4, INSADD5, CLAMNO, INSPC AS POSTCODE, 0 as INS_REF from claim_share WHERE claim_share.clamno ='''+ dmClaim.AdsFreeLett.FieldByName('CLAIMNO').ASString +''' AND claim_share.NAM ='''+ dmClaim.AdsClaim_Share.FieldByName('NAM').ASString+''''
end;
with TfmViewTemp.Create(Self) do try
Caption := cFreeFormPath +dmClaim.AdsFreeLett.fieldbyname('fileName').AsString ;
if sfileName = '' then
begin
//showmessage(TemFileName);
WPRichText1.LoadFromFile(TemFileName);
WPRichText1.MergeFields;
Hi,
>> In the table CONTRCTORS, the field CLAIM_NO does not exist so I want to pass it as a variable.
In the OnMailMergeGetText use a
f : TField;
f := DataSet.FindField(inspname);
if f<>nil then Contents.StringValue := f.AsString else
begin
// Field was not found
// use the variable:
if CompareText(inspname, 'CLAIM_NO')=0 then
Contents.StringValue := fClaimNo // has been assiged to form!
else Contents.StringValue := 'unknown: ' + inspname;
end;