loading object libraries / references dynamically

Hi all,

we're using some routines for excel output on different machines (using Excel Object Library.)

There we find different versions of excel and so different versions of object libraries:

How can we read the loaded references and load appropriate versions dynamically? (with GUID or so)

Any help appreciated,

cheers Ingo

Parents
  • How can we read the loaded references and load appropriate versions dynamically?

    That's a question for Microsoft, who invented COM without much forethought about your kind of problem.

    One approach is to eschew the COM libraries and use object creation by name...

    Dim oExcel As Object
    Set oExcel = CreateObject ("Excel")

    CreateObject looks for whatever COM class is registered with name Excel.  That should work on different computers with different versions of Excel.

    What you lose by that approach is interface binding — you no longer see hints about object properties and methods, and VBA can't check at compile time that you're calling the interface correctly.   Build your prototype using the Excel library reference, and for production create a version using CreateObject.

     
    Regards, Jon Summers
    LA Solutions

  • Hi guys,

    thanks for he replies,

    @Jan
    sorry I'm no coder - so I don't konw exactly what information you looking for.
    Maybe you can please help me what you need exactly.

    @Jon
    bit the same - I don't know where to start with your information.

    I was thinking of somthing like this what I found for Excel vba.
    Is this adaptable for Microstation?

    Public Sub prcShowReference()
        Dim objReferences As Object
        For Each objReferences In Workbooks("Test.xls").VBProject.References
            Debug.Print objReferences.FullPath, objReferences.Name, _
                objReferences.GUID, objReferences.Major, objReferences.Minor
        Next
    End Sub

  • Sorry I'm no coder — I don't know where to start with your information

    You can't solve your problem without someone experienced with VBA.  When in-house experience is not available, then hire a contractor. Jan is not too far away from Frankfurt. 

     
    Regards, Jon Summers
    LA Solutions

Reply Children