Functions in Word document

  • Thread starter יצחק ברט
  • Start date
×

יצחק ברט

Hello.

I want to create different headers for some of the pages in one document,
but I don't want to use segments.
I thought that I can use a function that get as an argument the page number,
and return the appropriate header.
But how can I put the function in the header of my document? Can I use a
field for it?

Thanks a lot,
Itzchak
 
D

Doug Robbins - Word MVP

Use an { IF { PAGE } = # "True" "False" } field construction in the header
of the document. Note that you must use Ctrl+F9 to insert each pair of
field delimiters { }. Use Alt+F9 to toggle off the display of the field
codes and F9 to update the field. You should also check out whether the
STYLEREF field can do what you want.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
×

יצחק ברט

Thank you very much.

1. If I have a lot of possible headers, the use of the {IF} statement will
be complicated. Isn't there an option to use VBA functions in the document?

2. Can I use the {IF} statement to draw a page-border around some pages,
while the other pages will stay without page-border?

Thank again,
Itzchak
 
D

Doug Robbins - Word MVP

If you have your function create document variables such as

ActiveDocument.Variables("one").Value = "some text"
ActiveDocument.Variables("two").Value = "some other text"

etc.

and then in the header of the document, you insert the following field
construction

{ DOCVARIABLE { PAGE \* cardtext } }

The header of page one will display

some text

and that of page two will display

some other text

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

macropod

Hi Itzchak,

In a Word document, you can have three different headers and footers in a single Section - 1st page, Odd and Even. Beyond that, if
you want more header/footer variety, you have to use Section breaks and/or field coding. Using VBA doesn't change that - your VBA
code will still have to Work with what Word allows. You can, of course, use VBA to input the appropriate field coding.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top