Please accept our apologies for the late answer. Hope this will still be relevant
Also, I would like to note that PI Trends are considered a legacy feature in newer versions of PI DataLink (2013+) and will not work if you are running the 64 bit version of Excel. We suggest transitioning to native Excel trends.
That being said, assuming you are working on a sheet called Sheet1, and already have a PITrend object on it with a PI Trace using PI data and one using Excel data, the following objects exist in your VBA project:
You can use the PIArchiveData AddQuerySpec method to add a PI Tag trace to your trend
expression.AddQuerySpec Server,TagName, StartTime, EndTime, [Validate], [Filter], [TimeZone]
Note: the parameters in square braces are optional
You can add sinusoid to your trace by executing the following code :
'Add Sinusoid to the trend Sheet1.PIArchiveData1_Sheet1.AddQuerySpec sServer, "SINUSOID", "*-8H", "*"
In the case of data from Excel, the method you need to invoke is the ExcelData AddQuerySpecs Method
expression.AddQuerySpecs QueryRange, [FirstRowColHasNames], [RangeIsStatic], [RangeIsRowwise], [Stepped], [Filter], [TimeZone]
'Add Range K1:L25 to the trend Sheet1.PIExcelData1_Sheet1.AddQuerySpecs "$K$1:$L$25"
I suggest you take a look at this discussion which addresses the same subject.
Again this assumes that the PIArchiveData and PIExcelData objects in the first place. If they don't, you will need to create them by either adding traces from the PI Trend Control Wizard, or using the Excel Trend Wizard PIAddQuerySpec and ExcelAddQuerySpecs methods
You can find documentation about the aforementioned objects and methods at the following places on the machines where PI DataLink is installed
- For ExcelTrendWizard properties and methods, in the PITrend Control Wizard help: "%PIHOME%\HELP\PITRENDXL.HLP"
- For PITrend, PIArchiveData and PIExcelData, in the PITrend Control Programmer's Reference: "%PIHOME%\HELP\PITRENDAUTO.HLP"
Let us know if this helps, and again, sorry about the delay
Thanks for your response, but since I know understand this is a legacy feature, we won't be using it.
thanks for getting me on the right track here.