VBA - Get Tag properties (description, engineering unit,...)

Discussion created by VincentGillard on May 22, 2013
Latest reply on Nov 8, 2019 by ColinF

Hi !


Goodmorning everyone ! This is my first post on this forum and I am a new user of PI, so I hope that you will understand my problem...

I'm trying to get different properties of a tag using VBA in PI ProcessBook.

I think that the best way is to use the library "piapi32.dll".

So far, it does not fully work as it should, as I can only get the point id and the scale...

I also would like to get the tag description and the tag engineering unit, but it does not work...


Here is an extract of my program (I get the tagname using another routine):


'Library declaration

Declare Function pipt_findpoint Lib "piapi32.dll" (ByVal tagname$, pt&) As Long
Declare Function pipt_scale Lib "piapi32.dll" (ByVal pt&, Zero!, Span!) As Long
Declare Function pipt_descriptor Lib "piapi32.dll" (ByVal pt&, ByVal desc$, ByVal slen&) As Long
Declare Function pipt_engunitstring Lib "piapi32.dll" (ByVal pt&, ByVal engunitstring$, ByVal slen&) As Long

Status = pipt_findpoint(tagname, PIPtNo)

Status = pipt_scale(PIPtNo, Zero, Span)

Status = pipt_descriptor(PIPtNo, descriptor, 27)

Status = pipt_engunitstring(PIPtNo, EngUnit, 27)



So only the 2 first functions are working fine (get the point id and the point scale), last 2 does not work (no error message, just an "empty" answer)...


Would you have any idea of the problem ?


Thank you in advance !