Glad it worked. Now if only all answers were that simple. grin.

Tom


On 11/26/2011 6:26 PM, David wrote:
Tom and Aaron,
thanks. Works like a dream. We all still are learning. Smile.

----- Original Message ----- From: "Tom Kingston"
<[email protected]>
To: <[email protected]>
Sent: Saturday, November 26, 2011 11:02 PM
Subject: Re: Checking if an object is available


Initialize the MyFile variable as Nothing and reset it to Nothing
after every close. You're getting the error that it's not defined
because it isn't.

Hth,
Tom


On 11/26/2011 4:44 PM, David wrote:
In one of my apps, I am trying to figure a way to perform the
following; if such is possible, that is.

I have a FileSystemObject defined as FS. Then somewhere in the code,
I have a line like:
Set MyFile = FS.OpenTextFile( "test.txt", 1, False)
This to open a textfile object, in the Object MyFile.

A third place in the code, I want to check if the MyFile object is
active. If it is, I want to have it closed.
I tried this:
If Not MyFile Is Nothing Then MyFile.Close

This works in some cases, but other times I am getting an error
message, saying the object is undefined. Seems to me, if the object
has been in use once, it works, but not if there has been no call for
the object through the process.

OK, so my Question:
Is there any way for me, to check to see if an object has been
defined, and is active? Some way, that will not leave me with an
error message?

Thanks for any idea.





Reply via email to