What exactly is the problem you are experiencing? The cell populates but the formula does not resolve? Or something else?
I am unable to test on your DataLink version but on the version available to me the reason it doesn't work is because of syntax errors. In addition to changing the range to just one cell (A1 instead of A1:B1), these changes made it work for me:
pi_formula = "=PISampDat(" & Chr(34) & tag & Chr(34) & "," & Chr(34) & stime & Chr(34) & "," & Chr(34) & etime & Chr(34) & "," & Chr(34) & interval & Chr(34) & "," & boundarytype & "," & Chr(34) & PIServer & Chr(34) & ")"
Please also tell us more about your use case, perhaps we can suggest a better way than building DataLink formulas from VBA.
Well I'm trying to control PI with VBA codes, so I want to know how can I use compressed data, sample data and so on with a simple code of excel in order to make cycles, automatic plots and such. I'm starting with sample data but I couldn't make it work, I may no t know the right commands.
I changed my code with your suggestions and it worked pretty good. A1:B1 is necessary when you ask for the time stamps of the variable.
If you guys have some sort of dictionary of commands or simple codes for VBA (or any language) it would be very helpful.
Thanks a lot!
1 of 1 people found this helpful
For programming in Excel, our best reference is the PISDK.chm help file. It is usually located in %pihome%\help. This reference can also be found online here: https://techsupport.osisoft.com/Documentation/PI-SDK/title.html
For programming in ProcessBook using VBA, there is a specific Programmer's Help file that can be found inside ProcessBook by going to Help > PI ProcessBook Programmer's Reference.
2 of 2 people found this helpful
Another good resource for the syntax for manually populating the DataLink functions can be found on the Live Library. For example, here is the one for Sampled Data.
It seems that you are not really using VBA with PISDK, so the PISDK help file may not be as useful to you. General VBA help with Excel is pretty easily found on Google, and then you can use the Live Library DataLink documentation linked above for reference material on how to write the DataLink functions in your VBA code.
thanks a lot!!