Solved

Programmaticaly add letterhead template to existing Word Doc

Posted on 2009-05-15
2
551 Views
Last Modified: 2012-05-07
I have patient dictations that are prepared by a transcription department.  We currently print them on letterhead.  I am trying to eliminate the cost of buying, and use a word template, which I already have.

I want to programmatically (from Access) open each file and apply the template and resave it.  I already am opening each file and copy the text from it for another routine.

I would simply need a routine addition such as:

If there is no template, or if the template is Normal.DOT

  Then change to OTHER.DOT
   Save
   Close


Does this make sense?

Thanks for any help.

Troy

0
Comment
Question by:toverholt
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 24397098
You can attach another template to a document programmatically with

If  Doc.AttachedTemplate = NormalTemplate then
     Doc.AttachedTemplate = "C:\MyTemplates\NewTemplate.doc"
endif

but I doubt that it will do what you want.

The document part of a template is only used when a the document is first created. Thereafter the template parts such as macros, toolbars and styles can be employed, but text, layout etc. would not be affected simply by changing the template.
0
 
LVL 9

Assisted Solution

by:jkunrein
jkunrein earned 250 total points
ID: 24397130
Graham is quite right that applying a template does not apply the text.

You could, however, create an AutoText within that template.  Then, when you attach the template, you can insert the AutoText in the header of the document.  

This is an extra step in your VBA code, but it may do what you want.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now