[AccessD] Closing Word

Beach Access Software bchacc at san.rr.com
Sun Jan 21 09:19:55 CST 2007


Fine with me, if you can explain it. :o)

BTW, I just sent you an email Martin - I lost your phone numbers and need to
call.  Send 'em over and I'll call. 

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 Martin Reid
Sent: Sunday, January 21, 2007 7:08 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Closing Word

Rocky/Bryan
 
OK if I steal this section for the book?
 
Martin
 
Martin WP Reid
Training and Assessment Unit
Riddle Hall
Belfast
 
tel: 02890 974477
 

________________________________

From: accessd-bounces at databaseadvisors.com on behalf of Bryan Carbonnell
Sent: Sun 21/01/2007 13:58
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 <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
 
  




More information about the AccessD mailing list