4 Replies Latest reply on Jun 14, 2013 8:48 AM by Asle Frantzen

    Create Trend


      I need to create a Trend with VBA...

        • Re: Create Trend

          Hi Vitor,


          Some additional information about your requirement will be helpful here. For example are you trying to create the trend in ProcessBook? or you are simply thinking of doing this in other environments that supports VBA like Excel?

            • Re: Create Trend
              Marcos Vainer Loeff

              Hello Vitor,




              If you are willing to create a trend in a display of PI ProcessBook, please refer to the example below copied from PI ProcessBook Programmer Reference Guide.

              Public Sub CreateTrend()
                  'PB Symbol object
                  Dim oTrend As Trend
                  Dim sServer As String
                  Dim sTagName As String
                  sServer = "\\servername\"
                  sTagName = "sinusoid"
                  'add a trend object to the Symbols collection
                  'the Add function will return a reference to the trend object
                  'if successful
                  Set oTrend = ThisDisplay.Symbols.Add(pbSymbolTrend)
                  With oTrend
                  .Name = "TestTrend1"
                  'set the position and size of the trend
                  .Top = 14950
                  .Left = -14700
                  .Width = 1000
                  .Height = 750
                  'call the AddTrace function for every tag to be trended
                  .AddTrace sServer & sTagName
                  'this trend will display the previous 12 hours
                  .SetStartAndEndTime Format(DateAdd("h", -12, Now), "dd-mmm-yy hh:nn:ss"), Format(Now, "dd-mmm-yy hh:nn:ss")
                  'set the title text
                  .TrendTitle = "Trend Example"
                  End With
              End Sub



              Let us know if this example is helpful to you.