Link to home
Start Free TrialLog in
Avatar of ru2cool
ru2cool

asked on

Excel VBA - Can't create object

I am trying to create an object variable in VBA which will use the TypeLib Information Objects library and I'm working with Excel 2007.  I've done some research and discovered that the original file was named TLBINF32.DLL but was renamed to VSTLBINF.DLL.  I was able to find VSTLBINF.DLL on my PC and include it as a reference in my VBAProject.  However, when I try to initialize an object variable I get the following error message -


Run-time error '429':

ActiveX component can't create object

The code I used for testing is based on several examples I found on google.  Granted, they were all referencing the original file TLBINF32.DLL so I'm not sure if I need to do something different.  The main reason I am interested in this is so I can write code that will enumerate and list constants for various available COM/ActiveX objects.  Any assistance would be greatly appreciated.  The test code is listed below

Sub Test()

    Dim tliApp As TLI.TLIApplication
    
    ' The line below is where the error occurs.  If I replace it
    ' with a MsgBox showing IsObject(tliApp) then the return
    ' value is True.
    
    Set tliApp = New TLI.TLIApplication
    
End Sub

Open in new window

Avatar of Norie
Norie

Try using CreateObject.
 Set tliApp = CreateObject("TLI.TLIApplication")

Open in new window

Avatar of ru2cool

ASKER

imnorie, I tried that line of code but it yielded the same error message.  After further research, I don't think I'll be able to accomplish what I originally wanted to.  I searched the registry for the phrase 'TLI.TLIApplication' and it was not found.  I know that in the past I've always been able to find any other usable COM objects in the registry.  And, since I'm on a company computer, I don't have access to register anything that's not already there.

The article linked below is what gave me the idea to try this in VBA when I was unsuccessful with CreateObject("TLI.TLIApplication") in a VBScript file.  I guess my assumption was that VBA could still access the methods/properties of the object directly from the DLL file.  If that is actually case, please let me know what to do differently.

WSF Files
In the Visual Basic Editor, choose Tools->References. Look through the list for TLI Application. If you find it, add a check mark. If you don't find it, then you will have to manually add a reference to the appropriate DLL.
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ru2cool

ASKER

tdlewis, as originally mentioned, I did add a reference to VSTLBINF.DLL which is the newer version of the original file TLBINF32.DLL.  However, while VBA did recognize it as a valid reference library, it would not let me create any objects.  Please see the screenshots below -

User generated imageUser generated image
Avatar of ru2cool

ASKER

imnorie, I found a Microsoft article which indicates that the file TLBINF32.DLL was indeed shipped with VB6 but it makes no mention of Office.  And, VSTLBINF.DLL is located in the Office folder on my PC (C:\Program Files\Common Files\Microsoft Shared\OFFICE12\VS Runtime).  Article link below -

http://support.microsoft.com/kb/224331

I did try your suggestion regarding the variable declaration but the results were the same.  Code example below -

Sub Test()

    Dim tliApp As Object
    Set tliApp = CreateObject("TLI.TLIApplication")

End Sub

Open in new window

In the Visual Basic Editor, choose Tools->References, click on Browse..., browse to C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\VS Runtime, and select the file VSTLBINF.DLL.

Then try running your code again.
(or whatever version of Office you have installed)
Avatar of ru2cool

ASKER

tdlewis, I have already done what you are now requesting which is the main reason for my opening question.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The file is in a folder called VS Runtime, doesn't that kind of give you a clue that it's for Visual Studio(VS).

Have you looked for TLBINF32.DLL anywhere else?

For some strange reason I've got it in C:\Windows\SysWow64.

No idea why it's there and it probably shouldn't be but I know it works.
Avatar of ru2cool

ASKER

It is what it is I suppose.  Thank you all for the feedback.