Different Header and footer. Section jump

C

CC

Hello to everyone. This comes from Spain. Excuse my very poor english.

I have a word document, and i fill this document using visual basic code.

This document now has a header and a footer and creation works fine. All i
have to do is type text in it.

Now the problem is that this document has to have a header in first page,
and another header different for other pages.

I´ve read that i ´ve to use 2 diferent sections, one for the first page, and
another for the others.

The problem for me is how to know where to put the goto second section.

How can i know if i´ve fill the first page to goto second section ????. How
can i control the jump, because different font or page orientation will
change this jump.


Any help will be welcome. Many thanks. Greetings from Spain:

CC
 
J

Jay Freedman

Hi, CC,

You do *not* need a separate section just to change the header and footer on
the first page. Word has a setting to make a different first-page header and
footer. If you did this manually, the setting is in the File > Page Setup
dialog, on the Layout tab.

To do this in a macro, use one of these statements:

ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True

or

ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True

depending on how many sections your document has already (the first one
works if the document is only one section, or if you want to change all
existing sections).

Here is some sample code to show how to use the different headers and
footers:

Sub SampleCode()
With ActiveDocument.Sections(1)
.PageSetup.DifferentFirstPageHeaderFooter = True

.Headers(wdHeaderFooterFirstPage).Range.Text = _
"This is the first page"
.Footers(wdHeaderFooterFirstPage).Range.Text = _
"This is the first page"

.Headers(wdHeaderFooterPrimary).Range.Text = _
"This is a later page"
.Footers(wdHeaderFooterPrimary).Range.Text = _
"This is a later page"
End With
End Sub
 

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