7 Replies Latest reply on Aug 22, 2016 12:02 PM by lmlcoch

    Login to PI server through VBA



      I use the following code to try to login on a PI Server to automatically read data, calculate it en put the results back on the PI Server.

      After that I close the Excel application.

          On Error Resume Next

          Dim Cxn As New PISDKDlg.Connections

          Dim s As Server

          Set s = Cxn.Login(, "******", "******", False, False)


      Until PI Datalink 2010 this was working fine but the company upgraded to PI Datalink 2014 and despite of the code, now when I open the Excel file it pops-up a login screen.

      In this screen I have to put my login and pasword and select PI user authentication instead of windows authentication.


      Is there a way in VBA programming to avoid this pop-up so that the excel file automatically can be run to do the job it was doing in the older version?


      I try to find a programmers reference guide to VBA Datalink but cannot find it on your side of is the programmers reference of Procesbook the same as for PI Datalink?


      Best Regards;

        • Re: Login to PI server through VBA

          Hi Gustaaf,


          Since you are using the PI SDK for the connection, the manual you would want is the PI SDK help.  You can usually find this file in your %pihome%\HELP folder.


          For the issue you are facing, here is an excerpt from the manual:

          The PISDKDlg.Connections.Login method logs into the specified PI server using the specified PI user name and password. If the attempt fails, the PI-Login dialog is presented to allow the user to enter a new user name and password. If a connection is made, it returns a reference to a PI Server object for the connected server. There is an optional parameter which causes the PI-Login dialog to always be displayed

          Object.Login([PIServer] [, PIUser] [, Password] [, Override] [, ForceShow])

          Perhaps the login is failing?

          • Re: Login to PI server through VBA
            Steve Boyko

            Ideally your PI server security should not be based on PI user / password authentication. If possible you should be using PI identities and then you would not specify any user name / password in your code. PI would recognize the Windows domain user, map it to a PI identity, and you would get the access rights of that identity.

            4 of 4 people found this helpful
              • Re: Login to PI server through VBA

                I am not a PI administrator on the PI Server and the administrator doesn't want to change from PI user/password authentication to PI identities.

                I don't know why so I stuck with my problem. I made a workaround to my problem by using PI Datalink2010 SP1 on a virtual PC. This version of Datalink still works with my VBA code and connect automatically without a login pop-up window.

                Thanks for the replies.

                  • Re: Login to PI server through VBA

                    Hello Gustaaf,


                    Your workaround is to piggy-bag the connection of PI DataLink. Please note that starting PI DataLink 2015, Datalink is executed in a separate application domain for security reasons. This means that your workaround will break as soon as you upgrade to PI DataLink 2015 or higher.

                      • Re: Login to PI server through VBA

                        Hello Gregor,


                        I know this and I don't like this workaround too but if our IT department doesn't want to alter the server settings, of which I cannot access myself, I have to do this workaround to get things done until they want to alter these settings.

                        Because the Excel with PI Datalink 2010 is running on a virtual PC, that haven't got access to the internet, this version will not be updated in the near future. When they will upgrade this, I don't mind because if that time comes I'll be in retirement.

                  • Re: Login to PI server through VBA

                    Hi Gustaaf,


                    You may try un-checking the option "Prompt for credentials" (PI SDK Utility. Select Connections > Options) but not sure if it will work.  I think new version of DatLink will always prompt for credentials when all other protocols fail (WIS or Trust).


                    Kindly refer following KB article for behaviour of new version of DataLink with explicit login.

                    KB00766 - PI DataLink Explicit Login and Default User Behavior


                    1 of 1 people found this helpful