Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Word Template File
Caleb Hansen 
        
3 years ago
How can I take the following and use a template word file I created to output to:

DoCmd.OpenReport "BidR", acViewPreview, , "ProjectID =" & ProjectID, , "False"
    DoCmd.OutputTo acOutputReport, "BidR", acFormatRTF, _
        "\\Operations\Project Files\Bids\" _
        & Format(Date, "yyyy") & "\" & Me.ProjectName & "\" _
        & "Bid Files\" & Me.ProjectName & " - Quote - " _
        & Format(Date, "m.d.yy") & ".rtf", True, _
        "\\Operations\QUOTE TEMPLATE.dotm" 'I thought this is where I could point the direction to where I have my template file
    DoCmd.Close acReport, "BidR"

It is not using my template file "QUOTE TEMPLATE.dotm". Please help.
Kevin Robertson  @Reply  
          
3 years ago
It looks like you are using the wrong extension for a template.

.dotm is a Word Macro-Enabled Document.
.dotx is a Word Template.
Caleb Hansen OP  @Reply  
        
3 years ago
I tried .dotx as well and it's the same result.
Kevin Yip  @Reply  
     
3 years ago
Word templates don't work here.  DoCmd.OutputTo only works with templates for HTML and ASP documents.  To actually use a Word template file, you need to use Word VBA that will allow you to use templates properly.  You need to create a .dotm (not .dotx) file, which is a macro-enabled template file that will allow you to put code inside.  Put Word VBA code inside the template file that can grab data from Access.  It's a totally different thing to implement.  It's simple to run DoCmd.OutputTo, but simple things can't accomplish complex tasks.
Caleb Hansen OP  @Reply  
        
3 years ago
Thanks Kevin and Kevin. I was worried about that. You think that might be something that Richard could make a techhelp on? I really need to implement this somehow.
Kevin Yip  @Reply  
     
3 years ago
I don't have access to many of Richard's courses so I don't know if he covers this in his Word courses.  But you may consider taking a shortcut: use DoCmd.OutputTo to create your .rtf file in Access, then in Word, insert the .rtf file into your document.  The Word VBA for that simple:

     Selection.InsertFile FileName:="MyFile.rtf"

This is same function as in Word -> Insert -> Object -> Text from file.

I don't know how your Word template is set up, but if it is just a letterhead with a lot of blank space below, then inserting the .rtf file into the blank space would be the easiest.
Caleb Hansen OP  @Reply  
        
3 years ago
It's not in his output to word video. He talks about making more videos for creating word docs from Access reports but I haven't found any as of yet. I tried your method and the formatting gets all screwed up. It's the same as copying and pasting. For some reason when I outputto to an RTF file from Access it comes out just like the PDF version, but if I copy and paste that text over to another word doc things get really weird. Even if I keep source formatting, etc.
Kevin Yip  @Reply  
     
3 years ago
You can use DoCmd.OutputTo, then open the resulting file in Word, and use Word VBA to add whatever extra material that you would have got from the template.  What sort of template is it?  Letterhead, water mark, etc.?  If the template simply adds an extra header, footer, graphic, etc., then you can add them to the document with Word VBA.  If your template has formatting information like Word styles, it's a bit trickier.
Caleb Hansen OP  @Reply  
        
3 years ago
It's just the header and footer. I've actually started doing this in the Access VBA. It works well, except that it adds a bunch of odd blank space between the different sections of my report. I'll keep playing with it to see if I can fix that somehow.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/22/2026 9:25:54 PM. PLT: 0s