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 Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Create and save new word doc from a template
Mike 
    
13 years ago
In access, I am trying to create a new document based on a template and then save the newly created document under a different name, in a different location.  The new document generates itself well, but when I try to open it, there is an error that pops up saying  The file test.docx cannot be opened because there are problems with the contents.    The code that I am using is below.  The strange thing is that when I remove the save as line and save the document manually, I can open the new document up without the error.  What can I do to fix this problem?

Private Sub ReportToWord(FileName, NewFileName)

On Error GoTo ReportToWord_err
    Dim objWord As Object
    Dim ContInf As String    
    
    Set objWord = Nothing
    Set objWord = CreateObject("Word.application")    

    objWord.Documents.Open FileName
    objWord.Visible = True

    objWord.activedocument.SaveAs NewFileName
    Set objWord = Nothing

ReportToWord_exit:
Exit Sub

ReportToWord_err:
    MsgBox (Err.Description)
    Set objWord = Nothing
    GoTo ReportToWord_exit
End Sub

Private Sub Invoice_Click()

    ReportToWord "Z:\Forms\Templates\ Invoice.dotx", "Z:\Repairs\" & InvoiceNumber & " " & BilledTo & ".docx"

End Sub

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access 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: 5/15/2026 7:52:38 AM. PLT: 1s