6 Replies Latest reply on Mar 24, 2011 5:23 PM by dhollebeek

    How to hide unhide ProcessBook Toolbars using VBA?

      To start filling VCampus with live, I thought it would be a good idea to post what I have learned today by answering a Technical Support request.

       

      For browsing through the Toolbars, retrieve their indexes, names and current visibilty status the following code can be used:

      Private Sub CommandButton1_Click()
          Dim i As Integer
          For i = 1 To Application.CommandBars.Count
              MsgBox (i & " - " & _
                      Application.CommandBars.Item(i).Name & _
                      ": " & _
                      Application.CommandBars.Item(i).Visible)
          Next i
      End Sub

      The following code can be used to hide / unhide a specific toolbar selecting it by its index i.e. the Fullscreen toolbar:

      Private Sub CommandButton2_Click()
          ' True = unhide / False = hide
          Application.CommandBars.Item(8).Visible = False
      End Sub
        • Re: How to hide unhide ProcessBook Toolbars using VBA?

          Thanks for the post Gregor, this is nice!

           

          If I may, I'd like to add 2 tips here:

          1. You can also call the Toolbars by their name (rather than with their index number)
          2. You can use the "Not" operator to create a button that will toggle between visible and not visible:
          Application.CommandBars("Full Screen Toolbar") = _
            Not (Application.CommandBars("Full Screen Toolbar").Visible)

          For the second trick, make sure you use the latest version of PI ProcessBook (3.1+) or an earlier 2.x version, since there's been a version or two where that Visible property was somehow different (i.e. not Boolean) and the "Not" trick wouldn't work.

            • Re: How to hide unhide ProcessBook Toolbars using VBA?
              matthew.rivett

              OSIsoft provided us some code to open ProcessBook displays from a command line to a specific x,y,width and height. I have modified it to also allow Zoom-FitAll, Maximize, and which toolbars to make visible. If you have a video wall or other large monitors that have many copies of ProcessBook running it is pretty useful. We create batch files that load up all our displays to the correct positions and sizes. I can provide the code if anyone is interested.