Accessing Exposed Functions


Getting an object reference to myObjectiveOLAP from VBA


In all of the examples shown, you will see a preceding "o." in front of the myObjectiveOLAP function, this is the object reference to the myObjectiveOLAP library.


You must also generate an object reference either by using this example or creating your own.


To instantiate the myObjectiveOLAP from Microsoft Visual Basic for Applications or Microsoft Visual Basic you must bind myObjectiveOLAP to an object that you can then reference.


In all of the examples shown we do this check by calling the regQ function which is shown below.


The regQ function binds the myObjectiveOLAPXL.AddinModule to the Global object "o". Once "o" has been bound you can use it to reference the myObjectiveOLAP functions i.e. o.connect o.mooAttached etc.


Global o As Object

Global oregistered As Boolean

Public Function regQ() As Boolean


If oregistered = False Then

Set o = Application.COMAddIns.Item("myObjectiveOLAPXL.AddinModule").Object oregistered = True

Else

   regQ = True

End If

End Function



Accessing functions within the myObjectiveOLAP library directly


Instead of creating an object reference as above you can access functions directly by fully qualifying the function as below:


Dim ret_ as string


ret_ = Application.COMAddIns.Item("myObjectiveOLAPXL.AddinModule").Object.mooExecuteOnly("LMT TIME to NULL")


This method can be safer, especially in Excel versions lower than 2007 where the object reference can be lost.