[RESOLVED] Testing if CreateObject() will work before calling it
Well I'm not one to use "On Error GoTo Blah" becuase when I have subs that do a lot of things that could error, it gets messy, and I don't like spliting them into their own subs.
Is there some ObjectExists()? Guess I could write one, just don't want to re-invent the wheel.
Re: Testing if CreateObject() will work before calling it
Why not create a boolean function for testing it ?
VB Code:
Public Function ObjectExists(ByVal class As String) As Boolean
On Error GoTo NotExists
Dim obj As Object
Set obj = CreateObject(class)
ObjectExists = True
Exit Function
NotExists:
End Function
Or you could check if the object's reference exists in registry (HKEY_LOCAL_MACHINE\SOFTWARE\Classes).