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 
Set New VBA code issue
Roland Roberts 
    
5 years ago
Posted this on TechHelp but not sure if it met the criteria:

When calling Word from Access VBA using a "Set wrdApp = New Word.Application" the instance created by Word includes the initial blank word document "Document1" (or some other next in line number).  Opening the document you wish to really manipulate with a "Set wrdDoc = wrdApp.Documents.Open(...)" still leaves that blank "Document1" hidden and open in the Word Documents collection.  When you close your document and quit the Word App (including setting the wrdApp and wrdDoc to Nothing AFTER you have used a Close on the Doc and a Quit on the App still leaves Word as a running process (because the "Document1" was never closed/cleaned from the Word Documents collection) according to the Windows Task Manager.  Is there some VBA code you can use to close the VBA instance of Word to not leave Word still running because of this blank hidden document when you use the New keyword in Set for Word? (Not shown on your taskbar BUT WinWord showing in Windows Task Manager and therefore consuming system resources).  Many users might be unaware this is happening.
Roland Roberts OP  @Reply  
    
5 years ago
p.s. Using the "SaveChanges:=wdDoNotSaveChanges" switch on the Close and Quit do not help.  This is for Access 2010. Maybe fixed in later versions but don't know that because don't have those versions.
Richard Rost  @Reply  
          
5 years ago
Hi Roland. I'll be honest with you. I haven't done anything with Word automation in YEARS. I've never encountered this problem before, but when I get a few spare minutes, I'll look into it. Automating Word from Access is something I've been thinking about spending more time on because I know a lot of people like to use it. I can generate 99% of what people need in Access alone, so automating Word hasn't been a priority. However once in a while it's nice to construct a Word document like a brochure or newsletter in Word using Access data so then you can tweak it in Word.
Roland Roberts OP  @Reply  
    
5 years ago
Seems this problem is also in Excel automation which uses a "Book1" on initial load according to my initial google search.  You really never know it is there UNLESS you happen to examine the processes running through Windows Task Manager.
Richard Rost  @Reply  
          
5 years ago
Very interesting. I'm sure there has to be a WinAPI you can use to kill a process.
Richard Rost  @Reply  
          
5 years ago
Roland Roberts OP  @Reply  
    
5 years ago
Although your URL appears to be quite helpful for VBA code to terminate ALL instances of a certain process running, it would also terminate any legitimate instances that might be running when you start it (i.e. perhaps even by other users on a Network or any open Word instances you had at the time you started your "Set wrdApp = New Word.Application" VBA procedure. I suppose I could modify it to show if any other Word processes were running by somehow getting the usernames for the process that is running and allowing the loop to ask whether to kill the process or not, then only killing the ones with my username.  That would require me though to then make sure I didn't have any other Winword processes running when this procedure starts OR perhaps even modifying it further to first pick up the filehandles of each running instance of Word BEFORE my "Set wrdApp = New Word.Application" line and storing that in an array for what not to terminate.
Richard Rost  @Reply  
          
5 years ago
Indeed. Like I said, this is outside of my area of expertise. I'll play with it when I get some free time.
Roland Roberts OP  @Reply  
    
5 years ago
Since I have not delved into the Windows API except once years ago, do you have any courses that go into depth on how to pull this kind of data from the API?  Thanks.
Richard Rost  @Reply  
          
5 years ago
Courses? No. Haven't gotten that in-depth with WinAPI.
Roland Roberts OP  @Reply  
    
5 years ago
Thanks for your help.  I'll keep searching for a solution and hopefully won't have to get too involved with Windows API programming (and learning the C and/or C++ programming language).
Roland Roberts OP  @Reply  
    
5 years ago
PROBLEM SOLVED! - The issue actually has to do with having the preview pane on in Windows File Explorer.  The preview pane creates a Winword process in Windows Task Manager (uses up about 50 MB of available memory) that persists without showing Windows as open on your taskbar as long as you have an open Windows File Explorer (even minimized) showing a Word document in the preview pane.  Sorry for wasting your time.
Richard Rost  @Reply  
          
5 years ago
Oh no... never a waste of time. I enjoy problems that I have never encountered before. Like I said, this was something out of my wheelhouse. I haven't done a lot with Word automation over the past... oh... decade or so. I wish I had enough free time on my hands to dig into stuff like this. I've been busy all day recording lessons. I'm glad you solved it yourself though. Doesn't that feel good? :) Keep the questions coming. Hopefully next time I'll be able to give you some productive input.

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/6/2026 10:36:17 PM. PLT: 0s