using letterhead automatically

R

R. Choate

I have a Word template with a company letterhead which I wish to call on in my code, or otherwise I just want to always use the
letterhead for my code-generated letters on the first page only (if there happens to be >1 pgs, else obviously use it on the only
page). Please advise. I seem to be stuck in the mud.

Richard
 
O

old man

Hi,

If you goto View Header Footer, then click on the Page Setup Icon then click
on the layout tab you can check different first page and it will allow you to
create a unique header for the first page of a document.

Old Man
 
R

R. Choate

Hi,

Thanks for that info. I was aware of that option in Word, but my project is fully automated and creates the letter completely via
code. I can't use that by itself or manually because of the previously mentioned situation. I do intend to specify different 1st
page in my code, but making that 1st page a specific letterhead background from a Word template (.dot) is another matter completely.
Do you know how to write code to do all of what I described? Hopefully I am in the correct newsgroup. I thought this was for VBA
users.

--
RMC,CPA


Hi,

If you goto View Header Footer, then click on the Page Setup Icon then click
on the layout tab you can check different first page and it will allow you to
create a unique header for the first page of a document.

Old Man
 
G

Graham Mayor

This forum is for vba users, but sometimes vba isn't appropriate for the
task in hand. Why re-invent the wheel when Word provides the tools? Your
document will have to be created from a template as Word is a template
driven application. By far the best way to do this is to start from a
template created to do the job rather than create one on the fly. If you do
that then you can create a separate first page header with no problem.
Create a new document from the company template then modify that and save it
as a template to be used with your code - see
http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

R. Choate

I am clearly not articulating my situation well and I apologize for that. I don't wish to waste anyone's time. My primary file is a
Word template which houses a few userforms and about 20 modules. The file accepts some user entry and connects via ADO to an Access
db to extract some more needed data (to save the user a ton of time), and then it connects to Goldmine db for contact info so the
user doesn't have to type in all of that stuff. Since it is a public accounting letter to clients, it almost always continues on to
ultimately create a pdf file, and in many cases the code creates a new email message and attaches the new Word letter to it and then
remains open for the user to type in the email verbiage. All in all, it is a very large and comprehensive template. I think it took
me from six to nine months to build it back in Y2K with a little inherited code and the rest all new. Anyway, as you can see, I'm
already using a template to create the primary result, the letter itself. I have the letterhead in a separate template file.



Sure, I can type a letter just using the letterhead template file and tell it I want different 1st page, but that would not take
advantage of all of the features provided by the other, more elaborate (and more important) template which write the letter in the
first place. The main letter template creates hundreds or even thousands of possible combinations of sentences and they are
contextual in their construction. The user gives the template enough info in the userform for the code to go forward and type the
letter. I have got to have a wedding between the letterhead template and the letter creation template. This is not "re-inventing the
wheel". I simply already have a template which I must use and I need the letter generated by that template's code to be typed on the
letterhead which is supplied by the other template file. Please help me to accomplish that if you can think of some code or leads to
code which will allow me to accomplish this all without user intervention.



Thank you very kindly for suffering through my longer explanation.


Richard
--
RMC,CPA


This forum is for vba users, but sometimes vba isn't appropriate for the
task in hand. Why re-invent the wheel when Word provides the tools? Your
document will have to be created from a template as Word is a template
driven application. By far the best way to do this is to start from a
template created to do the job rather than create one on the fly. If you do
that then you can create a separate first page header with no problem.
Create a new document from the company template then modify that and save it
as a template to be used with your code - see
http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Russ

You can recreate your letterhead(s) and store it(them) in autotext in your
template, then later with vba code insert which one you need where you want.
Look up autotext in Word VBA help for examples.
 
R

R. Choate

Thanks. I'll look into it and hopefully be able to use that type of solution and still have the letterhead only show up on the first
page. The letterhead is not text, per se. It is graphics. Although it is mostly text, it goes not only across the top but down the
left side as well. I'll see what the good ol Word VBA help has to say.

Richard
--
RMC,CPA


You can recreate your letterhead(s) and store it(them) in autotext in your
template, then later with vba code insert which one you need where you want.
Look up autotext in Word VBA help for examples.
 
S

Shauna Kelly

Hi Richard

Some comments that might help. Here I've used the word "letterhead" to mean
the combination of images and/or text that you want to appear on the first
page of a letter.

1. When you create an AutoText, if you include the end-of-paragraph marker
in the AutoText, then Word will respect all the styles or direct formatting
you have applied to the content you're saving as an AutoText. That would be
appropriate for the letterhead. And, when you insert such an AutoText, set
the RichText argument to True.

2. When you create an AutoText, if you don't include the end-of-paragraph
marker, Word stores only the text. That is appropriate for inserting
unformatted text into the middle of your document--perhaps into the middle
of a paragraph. The text will taken on the style and direct formatting of
the text around it. Generally, you set RichText to False in this case.

3. The source of your letterhead (ie whether typed by hand, or copied and
pasted, or generated by doing File > New and choosing a template that has
the letterhead in its header) is completely unrelated to whether or not that
letterhead appears in the header of the first or odd or even pages. That
depends on the properties of the first Section in the document. You'll need
to set the Section properties so that .DifferentFirstPageHeaderFooter is
true. VBA Help provides examples.

For more information on what to do, see
Working with sections
http://www.word.mvps.org/FAQs/Formatting/WorkWithSections.htm
and
Setting up letter templates
http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm

For how to find out what objects and properties to use see
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
R

R. Choate

Thanks for your advice, Shauna. I will look over all of this very carefully as I play with this whole letterhead dilemma again. Not
every letter "wants" the letterhead applied to it. That is determined my a user decision that is indicated by checking a checkbox on
the userform. I thought I had gone over this whole auto-text subject before, but I did not know about the paragraph marker thing. I
do know that I was getting all kinds of problems. Everything from having my real headers and footers messed up by the letterhead to
having the letterhead show up again if there was a 3rd page and so on. I know that sounds like somebody told it to do an odd pages
only setting, but I don't think that happened. I just know that by having the letterhead in the same file as the template I was
using to generate the letters, things went badly. I guess the file itself has styles and settings which the letters it generates
inherit, but I am also giving lots of specific instructions regarding headers and footers, margins, fonts, you name it, via code. I
hope I get all of this sorted out quickly.

Thanks again !

Richard
--
RMC,CPA


Hi Richard

Some comments that might help. Here I've used the word "letterhead" to mean
the combination of images and/or text that you want to appear on the first
page of a letter.

1. When you create an AutoText, if you include the end-of-paragraph marker
in the AutoText, then Word will respect all the styles or direct formatting
you have applied to the content you're saving as an AutoText. That would be
appropriate for the letterhead. And, when you insert such an AutoText, set
the RichText argument to True.

2. When you create an AutoText, if you don't include the end-of-paragraph
marker, Word stores only the text. That is appropriate for inserting
unformatted text into the middle of your document--perhaps into the middle
of a paragraph. The text will taken on the style and direct formatting of
the text around it. Generally, you set RichText to False in this case.

3. The source of your letterhead (ie whether typed by hand, or copied and
pasted, or generated by doing File > New and choosing a template that has
the letterhead in its header) is completely unrelated to whether or not that
letterhead appears in the header of the first or odd or even pages. That
depends on the properties of the first Section in the document. You'll need
to set the Section properties so that .DifferentFirstPageHeaderFooter is
true. VBA Help provides examples.

For more information on what to do, see
Working with sections
http://www.word.mvps.org/FAQs/Formatting/WorkWithSections.htm
and
Setting up letter templates
http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm

For how to find out what objects and properties to use see
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
D

Doug Robbins - Word MVP

I would have a couple of templates, one with the letterhead and one without
and then the code would use the appropriate one based on whether the user
had checked the check box or not.

--
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
 
G

Graham Mayor

Me too - I really don't like the idea of formatting documents on the fly
from vba using a standard blank template. It is much simpler to populate
documents created from pre-configured templates where all the layout work is
already done.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

R. Choate

Hi,

Thank you for your advice. In my situation it is a bit late for me to change course. Additionally, my application generates several
different types of letters for which a single template setup would not have served each need, thus the code-driven
instructions/changes. I do currently have, as you recommended, one template with the letterhead and one without. I just need to
understand how to make the one without the ltrhead call on the one with it (via code), and apply that letterhead to just the 1st
page (assuming the user has selected to use ltrhead and that there will be more than one page). By the way, it is not known until
the letter generation is complete whether there will be more than 1 page. I have already handled the part about dealing with the
user specifying if they want to use ltrhead.

Seems like my biggest problem was the ltrhead was messing up my 2nd page headers and footers that are created via code. The
headers/footers are really very simple and use a small header space for the header (2 or 3 lines at most), but I recall that the
ltrhead template was changing the size of my header and making it very large, perhaps trying to put the entire ltrhead in the
header. What is the best way to call on that ltrhead template from the other one?

Thanks !

Richard
--
RMC,CPA


I would have a couple of templates, one with the letterhead and one without
and then the code would use the appropriate one based on whether the user
had checked the check box or not.

--
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
 
D

Doug Robbins - Word MVP

You should set up as many templates as you need, the way that you want them
(that is with headers, with different first page header, without hearders,
etc. etc..)

Then in your userform you provide a means for the user to select the
appropriate template and then use the command

Documents.Add("template") to create a document for the rest of the code in
your user from the act upon.

--
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
 
G

Graham Mayor

You need to decide early on in your code which of the templates is required
to create the document and then start from that position by opening a new
document based on that template and using that to assemble your document.
You cannot apply the required template after you have started building the
document. If the whole purpose of the exercise is to simplify the code, then
really you should rethink the whole process, for at the moment you are
pushing against string. No wonder it is complicated.

For a start, what is it that is in the subsequent page headers of the
document that differs between letter types? Standard business letters should
have the same format regardless of what they contain. You can probably
achieve what you want with a standard header using StyleRef or DocProperty
fields and thus you can create the first and subsequent page headers in the
template and forget about them.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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