YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Calling DataLink Functions from ProcessBook using VBA Options · View
sohojinks
#1 Posted : Sunday, September 06, 2009 5:57:49 PM
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
Sponsor  
 

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.
sohojinks
#2 Posted : Sunday, September 06, 2009 6:46:46 PM
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?
RJK Solutions
#3 Posted : Sunday, September 06, 2009 8:24:23 PM
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
sohojinks
#4 Posted : Sunday, September 06, 2009 8:29:05 PM
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) & ")"
sohojinks
#5 Posted : Sunday, September 06, 2009 8:47:18 PM
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
sohojinks
#6 Posted : Sunday, September 06, 2009 8:53:46 PM
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!!!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.