2 Replies Latest reply on Aug 23, 2018 5:43 PM by william.flannelly

    Pulling Tag Data From Server Directly Through VBA

    william.flannelly

      So I have been looking for a way to do this for a while and only found a couple threads which did not help.

      I am using PI Processbook 2015 and trying to pull tag values WITHOUT having to use the display value object. I want to pull multiple tag values from multiple servers at the same time stamp. The most logical way to do this seems to be fully through VBA.  My code is below just to pull data which I found in another thread, but i get an error every time "Compile error: User - defined type not defined" and that error is related to me defining a variable as a "Server" an a "PIPPoint".  Am i doing something wrong? Once i can pull the data from the server, i shouldn't have a problem with the rest of the code

       

          'Sub get_PIVal()

         

              'Dim srv As Server

              'Dim tagname As String

              'Dim tag As PIPoint

              'Dim tagvalue As Single

         

              'Set srv = Servers("server address")

              'tagname = "tag ID"

              'Set tag = srv.PIPoints(tagname)

         

              'tagvalue = tag.Data.Snapshot

       

        '  End Sub

       

      Thanks