Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Excel VBA - Can't create object

Posted on 2012-09-05
12
Medium Priority
?
2,551 Views
Last Modified: 2012-09-07
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
Comment
Question by:ru2cool
  • 5
  • 3
  • 3
  • +1
12 Comments
 
LVL 36

Expert Comment

by:Norie
ID: 38369124
Try using CreateObject.
 Set tliApp = CreateObject("TLI.TLIApplication")

Open in new window

0
 

Author Comment

by:ru2cool
ID: 38369190
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
 
LVL 10

Expert Comment

by:tdlewis
ID: 38369519
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 36

Accepted Solution

by:
Norie earned 375 total points
ID: 38369630
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
 

Author Comment

by:ru2cool
ID: 38369699
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
 

Author Comment

by:ru2cool
ID: 38369776
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
 
LVL 10

Expert Comment

by:tdlewis
ID: 38369804
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
 
LVL 10

Expert Comment

by:tdlewis
ID: 38369807
(or whatever version of Office you have installed)
0
 

Author Comment

by:ru2cool
ID: 38369904
tdlewis, I have already done what you are now requesting which is the main reason for my opening question.
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 375 total points
ID: 38371702
As Norie said, that component is for Visual Studio (the .Net versions). VBA (being based on VB) would require the older tlbinf file.
0
 
LVL 36

Expert Comment

by:Norie
ID: 38373328
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
 

Author Closing Comment

by:ru2cool
ID: 38377754
It is what it is I suppose.  Thank you all for the feedback.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question