Discussion Locked

Programmatically reference an ActiveX dll

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have been searching for the solution but without success.

Can I programatically make a reference to an ActiveX dll as an alternative to manually doing

Project > reference.

3 replies

by slayer_

set oObj = CreateObject("Class.object")

Example

Dim oXML as Object
Set oXML = CreateObject("Microsoft.XMLDOM")

Creates a DOM object.

When you are done using the object, set its reference to nothing

Set oXML = Nothing

This will free up the memory

Also, watch yourself on objects. An created object is considered "empty". If you set an object to nothing, it is not empty, but it IS nothing.

Put simply, this code will runtime error if your object was not created.

If Not Is Nothing Then 'Check if object has not been created

So a trick I have learned when dealing with objects in VB6 and especially VBScript, is to actually set all your object variables to "nothing" before you even use them. That way they are always non "empty".

This discussion is closed to new replies.