Solved

Programmaticaly add letterhead template to existing Word Doc

Posted on 2009-05-15
2
558 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

688 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