Macro Header

A

austin

I've written a header macro which includes the date and page number. But, I would also like to include as part of the header the salutation.

How do I do this? How do I tell word to look at the salutation then insert that line into the header?
 
D

Doug Robbins - Word MVP

Rather than creating a macro to do this, the normal thing would be to create
a template that has the header set up in it. Being a letter, you would set
the template up with a different first page header that the one that you
macro is now creating would be the primary header so that the first time
that it would appear would be on page 2 of the document.

To get the saluation to appear in the header, you could enter the saluation
into a bookmark and then in the header use a cross reference to the
bookmark.

There is a problem however with such an approach as if the user is entering
the details directly into a bookmark, it is very easy for them to destroy
the book mark (it's almost certain that they will) and then the cross
reference will not work.

The best thing to do is really create a userform in the template. That is a
custom dialog into which the user enters information such as the addressee,
the address, the subject, etc. and then this information is then inserted
into the document at the required locations which are defined by the
insertion of bookmarks into the template.

See the article “How to create a Userform†at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
austin said:
I've written a header macro which includes the date and page number. But,
I would also like to include as part of the header the salutation.
How do I do this? How do I tell word to look at the salutation then
insert that line into the header?
 
C

Charles Kenyon

If you want to copy the salutation into a header (rather than have it be in
the header) use a StyleRef field.

Take a look at: Letterhead Textboxes and Styles tutorial
http://addbalance.com/word/download/index.htm#LetterheadTextboxesAndStylesTutorial

You may also want to take a look at:

How to set up letterhead or some other document where you want one header on
the first page and a different header on other pages.
http://www.addbalance.com/word/headersfooters.htm This gives step-by-step
instructions.

Letterhead Tips and Instructions
http://home.zebra.net/~sbarnhill/Letterhead.htm

Template Basics
http://www.addbalance.com/usersguide/templates.htm

How to Create a Template - Part 2 - essential reading
http://www.mvps.org/word/FAQs/Customization/CreateATemplatePart2.htm



austin said:
I've written a header macro which includes the date and page number. But,
I would also like to include as part of the header the salutation.
How do I do this? How do I tell word to look at the salutation then
insert that line into the header?
 
A

Austin

Thanks Doug and Charles...both your recommendations where great

I ended up going to the VBA tips website as recommended by Doug and did just what I set out to do and even more. The Website is great Doug...thank you so much.
 

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