• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2719
  • Last Modified:

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

0
ru2cool
Asked:
ru2cool
  • 5
  • 3
  • 3
  • +1
2 Solutions
 
NorieVBA ExpertCommented:
Try using CreateObject.
 Set tliApp = CreateObject("TLI.TLIApplication")

Open in new window

0
 
ru2coolAuthor Commented:
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
0
 
tdlewisCommented:
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.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
NorieVBA ExpertCommented:
VSTLBINF.DLL is for Visual Studio and TLBINF32.DLL is for VB6.0 and Office.

I've seen nothing about a name change to either.

What happens when you declare tliApp as Object instead of TLI.TLIApplication
and use CreateObject?
0
 
ru2coolAuthor Commented:
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 -

Reference libraryVariable declaration
0
 
ru2coolAuthor Commented:
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

0
 
tdlewisCommented:
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.
0
 
tdlewisCommented:
(or whatever version of Office you have installed)
0
 
ru2coolAuthor Commented:
tdlewis, I have already done what you are now requesting which is the main reason for my opening question.
0
 
Rory ArchibaldCommented:
As Norie said, that component is for Visual Studio (the .Net versions). VBA (being based on VB) would require the older tlbinf file.
0
 
NorieVBA ExpertCommented:
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.
0
 
ru2coolAuthor Commented:
It is what it is I suppose.  Thank you all for the feedback.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 5
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now