PDA

View Full Version : Late Binding VBIDE



fredlo2010
10-08-2014, 06:32 AM
Hello,

I am trying to create a code that uses the VBIDE but I cound it make it work with late biding.

Any ideas? This is my code below.


Option Explicit

Sub Sample()


Dim VBProj As Object
Dim VBComp As Object

' Create the objects. THis si the part with the error.
Set VBProj = CreateObject("VBIDE.VBProject")
Set VBComp = CreateObject("VBIDE.VBComponent")


Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents("a_Module")

End Sub


Thanks

fredlo2010
10-08-2014, 06:53 AM
I have also noticed a little bit of randomness in my code. It works for some users and does not work for others.

Is there anything that has to be checked while using the VBIDE model that I might be missing?

Thanks

Aflatoon
10-08-2014, 07:03 AM
You don't use CreateObject:

Option Explicit
Sub Sample()


Dim VBProj As Object
Dim VBComp As Object

Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents("a_Module")

End Sub


Do your users have trusted access to the VBA project in the trust center on their machines? If not, you can't use code that refers to the VBProject members.