2 Replies Latest reply on Jan 19, 2015 3:43 PM by gonmerciel

    Problem with Process Book Cursors from VBA code

    telventaustralia

      We are adding cursors to multiple trends in one process book display programatically from VBA code. We are facing some kind of display refreshment problem (although we are not sure). For example, we have 10 trends in one display and we add cursors to all trends from VBA code, sometimes we can see the cursors, but sometimes not. Generally if trends are visible on display, then it puts the cursor in right position. If out of 10 trends, 5 is in user visble display area, then we can see the cursors, but we can not see cursors in other 5 trends which are not user visible area. For example, we are using VBA code in a for loop for all trend as follows:

      ThisDisplay.Symbols.Item(TrendName).AddCursor
      ThisDisplay.Symbols.Item(TrendName).CursorTime = time as string
      ThisDisplay.Refresh
      Delay = 5000

      Also smetimes, it puts the cursors correctly if we put some message in the code like Msgbox("Testing Cursors").

       

      Would you please provide us some assisstance for the same. Thanks.  Mauricio

        • Re: Problem with Process Book Cursors from VBA code
          andreas

          Hi Mauricio,

           

          this sounds weird - I can add or remove cusors to trends no matter if they are visible in the screen or outside the visible area. Could you post a PDI that shows that behavior?

           

          here is the code:

          Private Sub CommandButton1_Click()
             
              Dim pbSymbol As Symbol
             
              For Each pbSymbol In Me.Symbols
                  If pbSymbol.Type = 10 Then
                      Dim pbtTrend  As Trend
                      Set pbtTrend = pbSymbol
                      pbtTrend.AddCursor
                      pbtTrend.CursorTime = "*-1h"
                  End If
              Next
             
          End Sub

          Private Sub CommandButton2_Click()

              Dim pbSymbol As Symbol
             
              For Each pbSymbol In Me.Symbols
                  If pbSymbol.Type = 10 Then
                      Dim pbtTrend  As Trend
                      Set pbtTrend = pbSymbol
                      Dim i As Integer
                      For i = 1 To pbtTrend.CursorCount
                          pbtTrend.RemoveCursor (1)
                      Next i
                  End If
              Next

          End Sub

          I am running this on a PDI that has 30 trends visible in 25% zoom and 4 trends visible on 100%. There is no difference in behavior in both cases.

           

          regards,

          • Re: Problem with Process Book Cursors from VBA code
            gonmerciel

            You could try using DoEvents instead of MsgBox.

             

            Regards,

            Gonzalo