Discussion created by night2day on Sep 21, 2012
Latest reply on Sep 21, 2012 by hanyong



until now i have used the following code to get filtered Sampedata in Excel 2003 under Windows XP.
(I have capsulated all PIPC-functionality years ago because of the terrible handling on prefilled formulas in Excel cells.)

' Procedure : vbPISampFilDat
' Author    : zeigerw
' Date      : 30.03.2008
' Purpose   : PI/Sampled Data mit Filter
Public Function vbPISampFilDat(ByVal strTag As String, _
                               ByVal strStarttime As String, _
                               ByVal strEndtime As String, _
                               ByVal strInterval As String, _
                               ByVal enuColRowMode As piColRowModeEnum, _
                               ByVal strPiServer As String, _
                      Optional ByVal showTimestamps As Long = 0, _
                      Optional ByVal strFilter As String = "", _
                      Optional ByVal showFiltered As Long = 0, _
                      Optional ByRef rngOut As Excel.Range) _
                               As Variant

  Dim arrResult()       As Variant
  Dim varResult         As Variant
  Dim lngOutCode        As Long
  Dim lngCount          As Long
  On Error GoTo proc_err

  Set cPIPC32 = New PIPC32.PIPC32Class
  lngOutCode = (1 * showTimestamps) + (2 * enuColRowMode)

  varResult = cPIPC32.vbPISampFilDat(strTag, strStarttime, strEndtime, strInterval, strFilter, CInt(showFiltered), CInt(lngOutCode), strPiServer)
  If (VarType(varResult) And vbArray) = vbArray Then
    arrResult = varResult
    For lngCount = LBound(arrResult, 1) To UBound(arrResult, 1)
      If arrResult(lngCount, 1) = " " Then
        Call ReDimEx(arrResult, lngCount - 1, UBound(arrResult, 2))
        varResult = arrResult
        Exit For
      End If
    Next lngCount
    If Not rngOut Is Nothing Then
      Range(rngOut, rngOut.Offset(UBound(arrResult, 1) - 1, UBound(arrResult, 2) - 1)) = arrResult
    End If
    If Not rngOut Is Nothing Then
      rngOut = varResult
    End If
  End If
  vbPISampFilDat = varResult


  On Error GoTo 0
  Set cPIPC32 = Nothing
  Exit Function


  MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure vbPISampFilDat of Modul modPiPC32_Wrapper"
  Resume proc_end

End Function

Now, after migrating to Excel 2010 and Windows 7 this Function shows a strange
behaviour.The first entry in the result is always "Resize to show all values", whats
comletly unnessessary.I think it is a dirfferent behaviour of a new Version aof pipc32.




So here is my question.
How can I build this query with the PISDK?
I can only find ArcValue, InterpolatedValue, RecordedValues
and TimedValues at the Data-Property of a PIPoint-Object.


Not any SampledValues.
Hope anybody can hear me. :-)


Greetings Wolfgang