3 Replies Latest reply on May 3, 2010 3:17 AM by hanyong

    How to change the server name for a trace in a PI Trend in DataLink (Excel)


      Does anyone knows a simple method to change the PI Server name for all tags of all PI Trends in an Excel workbook ?


      I see that I can add a PI Trend and add Traces or remove Traces from it, but how to read the currently configured traces modify them and add them back to the trend object ?


      Thanks !

        • Re: How to change the server name for a trace in a PI Trend in DataLink (Excel)

          Hi Max,


          We can access the trace configuration information through read-only object PIQueryObject and ExcelQueryObject, for PI data and Excel data trend respectively. Being that they are read-only objects, this means that we cannot modify the definitions directly, hence I think we need to remove the existing trace and replace it with a new trace using new server.


          An example is like:

          Dim tagpath As String
          tagpath = ExcelTrendWizard1_Sheet1.PIQueryObject.QuerySpecs(1).Name


          The Name property gives a full path to the tag though, like\\DEVPI\CDT158, and this means that we need to split the string to get the tagname. A good split function that can be used is found here. Using it, the rest of the codes to remove and replace traces (I think you should know as well)

          Dim tagarray() As String
          tagarray = Split(tagpath, "\")
          MsgBox tagarray(3)
          ExcelTrendWizard1_Sheet1.PIRemoveQuerySpec (1)
          ExcelTrendWizard1_Sheet1.PIAddQuerySpec "hanyongd6307", tagarray(3)