8 Replies Latest reply on Feb 9, 2018 8:49 PM by jasongogal

    Hyperlinks on ProcessBook Value Objects


      I have an AF attribute that reads a filename such as a Standard Operating Proceedure in .PDF format from a Table Lookup.  The value of the AF Attibute is displyed in a ProcessBook Element-Relative Value Object.  I want to add a hyperlink orequivalent functionality to the OnClick event of the value object.  Does anyone have some advice on how to accomplish this?  I can get the filename into a string variable, but I cant figure out how to open the .PDF file.

        • Re: Hyperlinks on ProcessBook Value Objects

          Hello John,


          I suggest using the Shell command.

          Private Sub Text1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
              Dim retVal As Double
              Dim appPathAndName As String
              Dim filePathAndName As String
              On Error GoTo ErrHandler
              appPathAndName = "AcroRd32.exe"
              filePathAndName = "C:\Temp\myPDF.pdf"
              retVal = Shell(appPathAndName & " " & filePathAndName, vbNormalFocus)
              Exit Sub
              MsgBox ("Error # " & Str(retVal) & vbCrLf & Err.Description)
          End Sub

          You may have to specify the full path to Acrobat Reader or ensure it's included into the "path" environment variable.



            • Re: Hyperlinks on ProcessBook Value Objects
              Asle Frantzen

              I use the ShellExecute command, and that eliminates the need for specifying that the pdf should open in AcroRd32.exe. Just let Windows open the file in its default software. Use this code:

              Private Sub Text1_Click(ByVal lvarX As Long, ByVal lvarY As Long)     
                  Dim filePathAndName As String
                  filePathAndName = "C:\Temp\myPDF.pdf"
                  ShellExecute 0, "Open", filePathAndName, "", "", vbNormalNoFocus
              End Sub



              and just make sure you put the following line at the very beginning of all the code in your vba (not just inside the function, but at line 1 in your file):

              Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


              • Re: Hyperlinks on ProcessBook Value Objects

                Hi John,


                You could also use the standard PI-ProcessBook "Button" object.


                Create one "Button" symbol that will open one of your PDF files. Enable scripting for this Button object.


                Then call the following code to change the PDF file name every time you change from one Element to the other:



                Dim objButtonDef As ButtonDefinition
                Set objButtonDef = Button1.GetDefinition()
                objButtonDef.Action = "manual.pdf"
                Button1.SetDefinition objButtonDef

                 Once this button is working in Run mode, you can move it over the Value objet and make it in invisible by changing its "Visible" property.




                Philippe @ Awegon









              • Re: Hyperlinks on ProcessBook Value Objects

                I have a similar challenge. Using a string builder data reference in AF, I am generating a dynamic file path string. I want to get a button into ProcessBook that will let me open the file at the location of the string value. So, in Asle Frantzen 's example, how would I open a file at the location of the value of an AF attribute, instead of C:\Temp\myPDF.pdf as per the line below? :

                1.     filePathAndName = "C:\Temp\myPDF.pdf" 
                • Re: Hyperlinks on ProcessBook Value Objects

                  For what it's worth, Button Links port to PI Vision, but VBA doesn't, so that's important to consider if you may eventually migrate there.  You might have to edit the Button Link because of web server security, but if it's a button link, we will be able to evaluate it in our secret project, if it's VBA, probably not.




                  PS. I may be somewhat biased, but PI World 2018 is a great place to find out about our latest initiatives including tracking me down and chatting.

                  • Re: Hyperlinks on ProcessBook Value Objects

                    I can only hope for a unicorn to whisk me to PI World 2018.


                    I'd settle for a dynamic link on a button.