Is there a way to find a list of tags by attribute (like "instrumenttag" or other attributes) in VBA? I'm looking a way similar to GetPointsSQL with where clause
If you must use VBA, then your best option is PISDK. Please note that PISDK is considered deprecated, as AFSDK is now the data access method of choice. However, AFSDK is .NET based so it cannot be used directly from VBA.
Using PISDK's Server object, you could use either the GetPoints method or the GetPointsSQL method to achieve the functionality of searching for points by attribute.
Below is an Excel VBA written by by our consultant that list all the tags that uses inputted instrumenttag.
1. Create a module in excel
2. Enter the code below
3. In an empty cell use the following formula
Note: Cell A1 is the cell that has the instrumenttag being looked up
Public Function tagName(InstrumentTag As String)
Dim oServer As PISDK.Server
Dim ptList As PISDK.PointList
Dim pt As PISDK.PIPoint
Set oServer = PISDK.Servers("AAAAAAAAA")
strQuery = "Tag = '*' AND InstrumentTag = '" & InstrumentTag & "' "
Set ptList = oServer.GetPoints(strQuery)
Select Case ptList.Count
tagName = "Not Found"
For Each pt In ptList
tagName = tagName & pt.Name
tagName = tagName & pt.Name & ", "
Note: Replace AAAAAAAAA with server/collective name.
I did some tests and it work perfectly.
Thank for your help guys
Retrieving data ...