Solved

Programmaticaly add letterhead template to existing Word Doc

Posted on 2009-05-15
2
557 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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…
If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

738 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