programming different headers on MSword doc after page 1

S

smHaig

d I need to change the headers on the pages greater than page 1 of a word
document. I am going this in vb 6 but if someone knows how to do this in
vba instead, I am sure it is very similar if not identical.
Thanks for any help on this
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?c21IYWln?=,
I need to change the headers on the pages greater than page 1 of a word
document.
First, you need to familiarize yourself with how Word handles headers and
footers. I believe you'll find an article on the topic at word.mvps.org.
Note that Word has an option in File/Page Setup/Layout to set "Different
first page header". You first need to activate this for the document,
otherwise anything you do will also appear on the first page.

Then you address the header/footer RANGE directly:
doc.Headers(wdHeaderFooterPrimary).Range.Text = "Text comes here"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

smHaig

I realize that I did not describe this correctly. It is actually a template
that I need to replace the non-page 1 headers. I have already selected the
non first page setting for the headers, but here is what I need to do with
these headers.

I need to put in two lines on the left side of the header, and the current
date on the right side. Currently, text appears in these places to indicate
where the headers need to be placed. There are not like the formfields that
I am filling in on the body of the template. There I can reference the form
field name and place a value into it with code. But I am not sure how to do
this with the header given the fact that it is two lines on the left and the
date on the right.

I see that the code you gave me would work for the first line and I suppose
I can introduce blanks and then put in the date at the right side, but not
sure about placing text on a second header line. Also there may be an easier
way to put the date on the right without using the crude method I suggested
above.

SM Haig
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?c21IYWln?=,
I need to put in two lines on the left side of the header, and the current
date on the right side. Currently, text appears in these places to indicate
where the headers need to be placed. There are not like the formfields that
I am filling in on the body of the template. There I can reference the form
field name and place a value into it with code. But I am not sure how to do
this with the header given the fact that it is two lines on the left and the
date on the right.

I see that the code you gave me would work for the first line and I suppose
I can introduce blanks and then put in the date at the right side, but not
sure about placing text on a second header line. Also there may be an easier
way to put the date on the right without using the crude method I suggested
above.
As I see it, you'd have two basic choices.

1. Analagous to the form field approach: Insert three bookmarks. (Select the
placeholder text you currently have, one item at a time, then Insert/Bookmark).
Assign the content: doc.Bookmarks("Name").Range.Text = "the text"

2. As I suggested in my previous reply, but positioning the three items:
Set rng = doc.Headers(wdHeaderFooterPrimary).Range
rng.Text = "First item" & vbTAB & "Second item" & vbCR & "third item"

vbTAB inserts a Chr$(9); vbCR a Chr$(13). In the template, delete all text you
currently have. Select the remaining paragraph mark and assign a right-aligned
tab stop to the right margin. The second item will then automatically position
at that tab-stop.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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