Beach Access Software
bchacc at san.rr.com
Sun Jan 21 09:18:57 CST 2007
SO everything's OK. Doc is open. Pointer is gone. I've cleaned up after myself. Are you trying to tell me I did something right? (Well, even a blind squirrel finds a nut once in a while) HOWEVER, after my code finishes, and the doc is still open, shouldn't I see WINWORD running in the processes form? Rocky Smolin Beach Access Software 858-259-4334 www.e-z-mrp.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bryan Carbonnell Sent: Sunday, January 21, 2007 5:58 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Closing Word On 1/20/07, Beach Access Software <bchacc at san.rr.com> wrote: > In the process I noticed that WINWORD was left open in the Processes form of > the Task Manager, even after I closed the word doc. So I added Set objWord > = Nothing and that solved the problem. However I can't explain why, even I can explain why THAT happens. When your original code ran, you got a pointer to a Word object and held it. You never did release it. So even though you closed the doc, maunally or otherwise, Access still had the pointer to Word, and wouldn't let it close properly. Remeber that VB(A) doesn't have really good "garbage collection" built in. You need to release pointers to objects, etc explicitly to keep from having weird things happen. > after the code executes the Set objWord = Nothing line, the word doc still > stays open. That's OK with me. I don't care. But it is curious that I can > set the object pointer to nothing and the word doc is still open. Why is it weird? Word is a separate application, so when you create a Word object, you are opening Word. Unless you explicitly close it again in your code, it will stay open. That's why, if you are not careful, you can get hidden instrances of it running. Think about it this way, if you opening a recordset in code, would you just exit your procedure without at least setting the recordset ot nothing? So why would Word, (or Excel, or Powerpoint, or any other automation server) not need to be treated the same way? -- Bryan Carbonnell - carbonnb at gmail.com Life's journey is not to arrive at the grave safely in a well preserved body, but rather to skid in sideways, totally worn out, shouting "What a great ride!" -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.3/642 - Release Date: 1/20/2007 10:31 PM