It is a good practice to free the memory taken up by an object variable after
you no longer need it. You can release the object by setting it to Nothing, as in the line
Set xl = Nothing
where xl is the name of the COM component's object variable.
Detecting Whether a Variable Is Instantiated
If an object variable holds a value of Nothing, then the variable doesn't
currently hold an instance of any object. You should check an object variable to see if it
holds Nothing before attempting to refer to it in your code with a line such as
If xl Is Nothing Then ...
Although it might seem contorted, you will often see syntax such as the following
in applications that use COM component objects:
If Not xl Is Nothing Then
'Do some stuff with the xl object
End If
<< Previous | Contents
| Next >>