Nick D'Orazio

Using PiCurrVal in VBA, Excel

Discussion created by Nick D'Orazio on Jan 8, 2013
Latest reply on Jan 9, 2013 by Gregor

An interesting thread came up on the OSIsoft Users Community that I'd like to copy here that may be of interest to beginning users of the PI SDK.

 

A user posted this:

 

Hi.  I am trying to use the PiCurrVal function from inside a vba macro.  If I was the write the formula (below, eq1) into a cell, it will correctly return the tag value.  However I am so far unable to call this from VBA.  I believe the formula is from the pipc32.xll addin, and I have enables this in tools>refrences.  I would expect the correct code to be as shown in (below, eq2), however this does not work.  I am new to this forum, can anybody shed some light?

eq1. PICurrVal("gtt2515.fin", 0, "AUSLFDKN4")
eq2. Pipc32.PICurrVal("gtt2515.fin", 0, "AUSLFDKN4")

 
Here is the response from user bmercer:

Learn the PISDK.   There are lots of examples in the help.   A short snippet below of a basic, basic, basic way to get the snapshot for the default PI server

In references check  PISDK 1.3 Type Library

 

Option Explicit

Dim srv As Server
Dim pt As PIPoint
Dim curval

Sub main()
Set srv = PISDK.Servers.DefaultServer
srv.Open
Set pt = srv.PIPoints("sinusoid")
curval = pt.Data.Snapshot

srv.Close
Set srv = Nothing
Set pt = Nothing
End Sub

 


Outcomes