|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 11 Location: Rochester, NY, USA
|
Hello all,
I'm trying to call a DataLink Macro from ProcessBook and I'm having trouble. Here's the code snippet:
Dim xlApp as Excel.Application Dim macroResult As Variant
macroResult = xlApp.Run("C:\Program Files\Rockwell Software\FactoryTalk Historian\Server\PIPC\Excel\pipc32.xll!PICompDat", "tagname", "*-1h", "*", 3, "historian", "inside")
This gives me an '1004' error, macro not found.
Any Ideas? I have tried not using the path to pipc32.xll, although including it seems to get me a little further than without.
John
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 11 Location: Rochester, NY, USA
|
I've changed things around a bit so that I recieve no error, however the macro doesn't return any pi values:
Dim xlApp as Excel.Application Dim macroResult As Variant
xlApp.RegisterXLL ("C:\Program Files\Rockwell Software\FactoryTalk Historian\Server\PIPC\Excel\pipc32.xll") macroResult = xlApp.Run("PICompDat", "tagname", "*-1h", "*", 3, "historian", "inside")
Are there any better ways of retrieving the values of a tag for a set period of time?
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
Hi John, Any reason you are looking to link to Excel rather than using PISDK from within ProcessBook? You can match up the Datalink functionality to PISDK calls... Example of retrieving the data via PISDK for the Compressed values Start Time/End Time Datalink call you posted: Code: ' Srv is a PISDK.Server object...
Dim Pnt As PISDK.PIPoint Set Pnt = Srv.PIPoints("tagname")
Dim PntVals As PISDK.PIValues Set PntVals = Pnt.data.RecordedValues("*-1h", "*", btInside)
Dim PntVal As PISDK.PIValue For Each PntVal In PntVals Debug.Print PntVal.TimeStamp.LocalDate & " " & PntVal.Value Next PntVal
Set PntVals = Nothing Set Pnt = Nothing
Depending on how you plan to use the data, don't forget about the Datasets in ProcessBook too. Rhys. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 11 Location: Rochester, NY, USA
|
I've shifted gears and am now trying to use Formula().
This gets me the furthest I've gotten, I am using the DataLink macro, but the time range gets wacky. No matter what time format I'm using, the year is usually set to 1900 and the month and day are off.
here's the snippet:
Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Dim xlWS As Excel.Worksheet xlApp.RegisterXLL ("C:\Program Files\Rockwell Software\FactoryTalk Historian\Server\PIPC\Excel\pipc32.xll")
xlWS.Cells(1, 1).Formula = "=PICompDat(" & Chr(34) & "Tagname" & Chr(34) & ", " & Chr(34) & "*-1h" & Chr(34) & "," & Chr(34) & "*" & Chr(34) & ", 0," & Chr(34) & "historian" & Chr(34) & "," & Chr(34) & "inside" & Chr(34) & ")"
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 11 Location: Rochester, NY, USA
|
Hello Rhys,
Thanks for the response! I get a runtime error 91 Object variable not set when I try to set Pnt... even though I've got references to every PI object library available. I know I'm missing something, just don't know what.
How can I thank/gift/donate you for all of your help?!
John
|
|
|
Rank: Member Groups: Member
Joined: 7/30/2009 Posts: 11 Location: Rochester, NY, USA
|
aha, I forgot to set the PISDK.Server object....
Thanks again!!!
|
|
|
|
Guest
|