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 
Print
Eric M 
    
11 years ago
What I m trying to do is use a command button on an Access form to:
Open a Word document.  
Automatically populate text form fields in the Word document using fields from the current Access form.  
And then print the populated Word document.
The Word document should automatically print on both sides of the paper.
I ve wasted several reams of paper, pulled out all but a few strands of my remaining hair, and quite possibly gone insane.  I m a beginner at VBA so if anyone tries to help restore my sanity, I d appreciate any additional explanations.  That said, this is what I have so far:

Private Sub DeliverySheetPrint_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn't open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
  'If Word isn't open, create a new instance of Word.
  Set appWord = New Word.Application
  End If
Set doc = appWord.Documents.Open("C:\Users\eric.m\Desktop\QA Form 17 latest.docx", , True)
  With doc
   .FormFields("txtCWP").Result = Me.CWP
   .FormFields("txtFullTask").Result = Me.FullTask
   .FormFields("txtJCN").Result = Me.UIC & "-" & Me.JSN
   .Visible = True
   .Activate
   End With
   appWord.PrintPreview
  Set doc = Nothing
  Set appWord = Nothing
End If
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub



Reply from Alex Hedley:

What isn't it doing? Are the fields not being populated?
You have a PrintPreview command, is it trying to print also?

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:51:42 AM. PLT: 0s