2 Replies Latest reply on Jun 17, 2016 1:13 AM by John Messinger

    Disabling access to VBA in Process Book display

    PatKelly

      We are working to restrict the user's access to build mode and the VBA in one Process Book display. Using VBA, we force the display to run mode every time there is a data update but it is still possible (using ALT F11, for example) for a user who knows PB well to get into the VBA code. Is there a simple way to disable access to the VBA code?

      Also, is it possible (via VBA) to disable toolbars?

        • Re: Disabling access to VBA in Process Book display
          Kenji Hashimoto

          We have Macro Protection option in processbook ini file.

          https://livelibrary.osisoft.com/LiveLibrary/content/en/processbook-v3/GUID-312C3C85-B06D-4271-AE9D-4FE08E093137

          Though it is needed to be done every machine.

          The other way is using VBA protection.

          Microsoft have following document.

          https://support.microsoft.com/en-us/kb/159748

          VBA Editor > Tools > VBAProjectProperties > Protection tab

          User cannot see/edit the code itself without password.

          In this case, administrator need to set password by each display.

          Also ProcessBook ini file can specify View-only mode.

          https://livelibrary.osisoft.com/LiveLibrary/content/en/processbook-v3/GUID-EBAC3EBE-9CFC-4E5D-97C0-BEC2D8DCAA28

          • Re: Disabling access to VBA in Process Book display
            John Messinger

            To restrict access to the VB editor in a single ProcessBook display, I would suggest simply setting a project password. You do this from within the editor, using the Tools => VBAProject Properties menu option.

             

            For disabling toolbars, you could take the approach of setting the fullscreen display option via code in the Display_Open() event handler, and call Application.FullScreen = True (gives a 'kiosk' like view). To prevent users from exiting full screen mode, you could try something like the following:

            Option Explicit
            
            Dim fsBar As PBCommandBar
            Dim WithEvents fsButton As PBCommandBarButton
            
            Private Sub Display_Open()
            
                Set fsBar = Application.CommandBars.Item("Full Screen ToolBar")
                Set fsButton = fsBar.Controls.Item(1)
                fsButton.Enabled = True    
                Application.FullScreen = True
                
            End Sub
            
            Private Sub fsButton_Click(ByVal Ctrl As PBCommandBarButton, CancelDefault As Boolean)
            
                CancelDefault = True
            
            End Sub
            

             

            Unfortunately, this won't prevent users from right clicking on a blank area of the bar at the top and showing any of the other toolbars. With additional code you could restrict access to these as well. Another downside to the approach above is that to close the display, you will need to forcibly close ProcessBook.

            I would ask what it is you want to prevent users from doing on the display. In a past project, we did something a bit similar, and the approach we took was to capture Click and DoubleClick events on trends etc, and set the value of the CancelDefault parameter that was passed in to True, effectively preventing things such as the user from maximising a trend, or opening the properties dialog, adding trend cursors etc. It's still not a perfect approach. I think if you want a true kiosk style experience for displays where users can't modify things, Coresight might be the answer. I understand though that not only can you not use VBA in PB displays under Coresight, but also Coresight might not yet be in your roadmap.

            2 of 2 people found this helpful