Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Export to Word 2 < Lock Subform | Immediate Refresh >
Back to Export to Word 2    Comments List
Upload Images   Link   Email  
Thank you Richard
Sami Shamma 
             
12 months ago
Thank you Richard.
It worked flawlessly.
Richard Rost 
          
12 months ago
Always glad to help
Sami Shamma OP 
             
12 months ago
Richard

I have implemented this. It works perfectly; however, after Word is open, my Access locks up. The only think I can do is switch between Access and VBA editor.  I have to close it with the "x"

I added a DoEvents, but did not help

Here is my code:

DetailsPrivate Sub ChapToWordBtn_Click()

    Dim FilePath As String, Word As Object, Doc As Object
    FilePath = "P:\DivReport-" & YMYear & "-" & YMMonth & ".pdf"
    
    'export pdf
    DoCmd.Echo False
    DoCmd.OpenReport "DivR", acPreview, , "YearMonthID= " & YearMonthID
    DoCmd.OutputTo acOutputReport, "DivR", acFormatPDF, FilePath, False
    DoEvents
    
    'open Word
    Set Word = CreateObject("Word.Application")
    Word.Visible = True
    
    'open pdf in word
    Set Doc = Word.Documents.Open(FilePath)
    DoEvents
    
    'clean up
    Set Doc = Nothing
    Set Word = Nothing

    Beep
    
End Sub
Sami Shamma OP 
             
12 months ago
Hi Richard,

Can you please also give us the code to the same but with an Excel instead of Word.  

Thanks
Richard Rost 
          
12 months ago
It's not locking up. You're turning Echo off and never turning it back on. Remember ECHO IS DANGEROUS.

Excel... already on the list. :)
Sami Shamma OP 
             
12 months ago
Thank you Richard Echo on solved the problem. Silly me.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Export to Word 2.
 

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/24/2025 12:18:22 AM. PLT: 1s