WPCubed Product Support

Insert a Variable in an exsiting Header

I already have a document with a Header with 4 lines, that includes a logo and some more information.

I need to insert a variable( that will be my client name), on the center of the last line of the header, each time I call de document.

Can you pls show me the code to do it?

Thanks

#1 ♥ 0
4.5k Views 3 users read 3 min

Hi,

  1. First you need do 'find the header'. WPTools 5 allows various headers on the sema file, but to simplify, just use
WorkOnText := wpIsHeader;
  1. Then you move the Caret to the end of the 'activetext', and add an empty line:
oWPRichText.CPPosition := MaxInt;oWPRichText.InputString(#13);
  1. Now you define the text attributes (center alignment in your case):
oWPRichText.CurrAttr.Alignment := paralCenter;
  1. And at last, add your text
oWPRichText.InputString(PChar('my text'));

You may hit the wall with some 'text formats', so take care of:

If you change anything, call this two functions to 'refresh' the things:

oWPRichText.ChangeApplied;
oWPRichText.DoUpdateCharAttr;

Hope this helps

Alessandro Fragnani

#2 ♥ 0

Hi,

Thanks to your answeer. It helped a bit, but I still have some ptoblems to control the things.

In my header, I have a line with a logo, then I have 2 tables with 4 lines each. The variables I have to put will be one at the first table and the other at the second table.

I could move to the first table or to the second table. Whwn I'm in a table, how can I move to the other?

#3 ♥ 0

Hi,

Well, you didn't say you wanted to move between tables in the original post 🙂

There is no 'automatic way' to move between tables. You must navigate through paragraphs, checking if ParagraphType is wpIsTable. But while doing this, check if you are 'still in the same table' (ParentTable, I guess), otherwise, it will not work.

Alessandro Fragnani

#4 ♥ 0
support

@gurevitz:
Thanks to your answeer. It helped a bit, but I still have some ptoblems to control the things.

In my header, I have a line with a logo, then I have 2 tables with 4 lines each. The variables I have to put will be one at the first table and the other at the second table.

I could move to the first table or to the second table. Whwn I'm in a table, how can I move to the other?

Alessandro, Thanks.

The answer is correct. A good way to start is

par : TParagraph;

par := HeaderFooter.Get(...).FirstPar;

now you can use a loop with par, par := par.NextPar to find your table and in this table access any cell using the Cols property.

Julian

#5 ♥ 0
This category is archived. No new posts are possible.