AnsweredAssumed Answered

Auto "Fit All" VBA Macro for ProcessBook 2014

Question asked by JoeHahn on Jun 21, 2019
Latest reply on Jun 21, 2019 by PhilippeCloutier

Hello all,

Full disclosure, I am really new (3 weeks) to using the PI System in general so much of my problem is that I usually don't know where I should even start looking for answers so any linked resources will be greatly appreciated. 


I have built 5 linked displays using PI ProcessBook 2014 and was asked by my supervisor to use a script to automatically select the "Fit All" view. I have programming experience (C++ and Python to be specific) but have never needed to use VBA before so I am going at this pretty blind. I did find a post from 2013 which seems to address this problem with the ThisDisplay.Zoom function. I added the code below to the ThisDisplay object in the ProcessBook Visual Basic Editor:


Private Sub Display_Open()
   ThisDisplay.Zoom = "FitAll"
End Sub


It is set to run on the Open trigger. The problem is that it doesn't seem to do anything. I asked one of the senior engineers in my department and he mentioned that there was a known bug with this function last time he tried working on it. I then found this thread, but the question seems to be for a C# .NET Add-in and not VBA. 


My question then is: is the code I have supposed to work and failing for some other reason or is my approach wrong altogether (the latter is my guess)? If it is the wrong approach, do I need to use a .NET Add-in or is this still possible with VBA?


Thank you in advance for helping!