I have the following code (using Osisoft PI SDK), which works.
Dim myPISDK As Object
Dim srv As Object
Dim pn As Object
Dim IPICalc As IPICalculation
Set myPISDK = CreateObject("PISDK.PISDK")
Set pn = CreateObject("PISDKCommon.NamedValues")
Set srv = myPISDK.Servers.Item("myPIServer")
Set IPICalc = srv
Set pn = IPICalc.ExpressionSummaries(dtI, dtF, "", TAG, 0, 0, 0, sample)
Did you noticed I am using late binding for everything (declare as object and use createObject to instanciate it) except for "IPICalc"?
That's what I need to do and I don't know how. I need to use late binding for IPICalc
to.
IPICalculation
is an interface from the Server object, which I get in the srv
variable.
It doesn't work if I declare as object
. When I do this: Set IPICalc = srv
, it get the IPICalculation
from the srv
object. If I declare IPICalc as object
, it doesn't do that.
Does anyone know if there is a way I can do this in VBA?
Among other things, I need to make it work without adding references to the VBA Project, so I need to do late binding, otherwise there will be errors since Excel won't know what is IPICalculation
to declare it.