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, "\")
ExcelTrendWizard1_Sheet1.PIAddQuerySpec "hanyongd6307", tagarray(3)
Thanks for the reply ! So there is no need for using the ExcelTrendWizard to do this ? I was trying to open an ExcelTrendWizard OLE object using
but this seems to fail.
Anyhow, is seems easier your way...!
For now, I simply added a Server alias in my PI SDK Connections. I'll let you know if I get to something better with the code!
Well I am using the ExcelTrendWizard object to delete and replace the traces in the Trend. The ExcelTrendWizard object can be accessed from a Excel sheet with a PI Trend already inserted. So instead of adding it as a new OLEObject, I just call the existing ExcelTrendWizard, it is named as ExcelTrendWizard1_Sheet1.