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
Ingo said: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.
CreateObject
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,
@Jansorry 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.
@Jonbit 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 NextEnd Sub
Ingo said: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.
okay - I've been coding in vba for some years but I was not taught in this field.So with some push in the right direction I think I can handle the task.
But I'm not familiar with COM classes. So any further advice for that could help.
Ingo said:I'm not familiar with COM classes
VBA is COM. Each class you create in VBA is a COM class and each UserForm is a COM class. So you may not think you are familiar with COM, but you're using it all the time when you write VBA code.
The key part of COM is that it defines an interface. Other apps., whether VBA, C++ or .NET, can use that interface. VBA can use an interface defined by some other app.
This COM Server article shows how that is done.