Solved

Programmaticaly add letterhead template to existing Word Doc

Posted on 2009-05-15
2
556 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

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

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
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 shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

830 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