AnsweredAssumed Answered

VBA to Change pi Display Time Range

Question asked by orftoden on Apr 1, 2015
Latest reply on Jul 10, 2015 by orftoden

Hello.  I am new to pi processbook and have some (although limited) experience with VBA.  I am trying to develop a series of screens that can "look back" x number of hours.  The screens will contain various values tied to pi tags that will be set to display the maximum value during the desired look back range.  The goal of the sheets would be to flag points that go above defined threshold values-- my plan is to display these exceedances using conditional formatting of objects.  The look back would be triggered though a button.




Although I am in the beginning stages of setting up my project, I have began toying around with VBA code to define the desired "look back" range.  Here is what I have come up with, but it does not seem to be functional:


Private Sub lookback_twelvehr()

Dim StartTime As String
Dim EndTime As String

StartTime = Now
EndTime = Now - 0.5
ThisDisplay.SetTimeRange Format(StartTime.Value, "dd-MMM-yyyy 00:00"), Format(EndTime.Value, "dd-MMM-yyyy 00:00")
End Sub


My questions are as follows:


1) Has anyone here attempted to create pages with similar functionality-- if so, have any advice or perhaps an example?

2) Am I on the right track as far as my code is concerned?  Suggestions are most appreciated!


I would like to thank any and all replies in advance.