The simple way to achieve this is with a .NET ProcessBook add-in, as opposed to file-bound VBA code. This will give you access to the PBObjLib.Application object and its events, such that you can implement event handlers around events like "NewDisplay", "NewProcBook", etc. You also gain access to the Display(s) within the PI ProcessBook environment and their events such as "Display_BeforeClose".
You can find templates on the vCampus Download Center (in the "Supporting Files" category) to get you started in .NET ProcessBook Add-Ins development. We also held a webinar on the topic and its recording is available here on the vCampus Auditorium. And of course, don't hesitate to post your other questions in this very forum!
Thanks, I was using the VB.NET toolbar template. The example I was looking for is on slide 15 of the presentation that goes with the recorded webinar. I glazed over it before because it is in C#. For any VB developers out there, the equivalent is this: ("OnDisplayActivate" can be whatever you want, m_App is assuming you use the same naming conventions as OSIsoft in the example templates)
Public Sub OnDisplayActivate(ByVal aDisplay As Display) Handles m_App.DisplayActivate
What I don't know is: should aDisplay be passed ByVal or ByRef? It is working with ByVal.
should aDisplay be passed ByVal or ByRef? It is working with ByVal.
Yes, use ByVal.