AnsweredAssumed Answered

Simple Code for VBA with PI2010 V4.2.1

Question asked by FernandoReyes on Oct 4, 2016
Latest reply on Oct 10, 2016 by FernandoReyes

Hi, I recently started using PI for data extraction, I have tried to use VBA codes for it but with failed results.

 

Sub RetrieveCompressedData()
    Dim result_range As Range
    Dim tag, stime, etime, PIServer, boundarytype As String
    Dim interval As String
    Dim pi_formula As String
      
    tag = "WF-UY-009-1171-Y3-A-009:50227"
    stime = "*-1h"
    etime = "*"
    interval = "10m"
    PIServer = "wonesepip01"
    boundarytype = "1"
     pi_formula = "=PISampDat(" & tag & ";" & stime & ";" & etime & ";" & interval & ";" & boundarytype & ";" & Chr(34) & PIServer & Chr(34) & ")"

 

                  
    Set result_range = Range("A1:B1")
    result_range.ClearContents
    result_range.FormulaArray = pi_formula
    result_range.CurrentRegion.Select
    Selection.Columns(1).NumberFormat = "dd-mmm-yyyy hh:mm:ss"
    Call dlresize

End Sub

 

Tried to use that code with no results.

 

hope someone can guide me.

 

Chers

Fernando

Outcomes