2 Replies Latest reply on May 22, 2015 11:50 AM by MattLab

    Programmatically (VBA) add a hard drive image in PI ProcessBook

    MattLab

      Hello,

       

      Does anyone know how I would go about adding a local image to PI ProcessBook through VBA?  I do not want to convert it to a symbol and then add it as a picture. I would like to select an image on the drive and then programmatic add it to the processbook UI.

       

      Kind Regards,
      MT

        • Re: Programmatically (VBA) add a hard drive image in PI ProcessBook
          pthivierge

          Hello  Matt,

           

          I believe the following code could do what you need, otherwise I would need more information to understand what you need to do:

          ' inserts an image on PB display
          Public Sub InsertImage()
              Dim image As Bitmap
              Set image = ThisDisplay.Symbols.Add(pbSymbolBitmap)
              Call image.Load("C:\temp\image.png", pbImageSizing.pbImageSizingRetainAspectRatio)
              image.Width = 150
               
              ' random positioning ... for demonstration only
              image.Left = -15000 + (Rnd * 1000)
              image.Top = 15000 - (Rnd * 1000)
              
              Debug.Print image.Left, image.Top
              
          End Sub