Transfer Data to the Synthesis Data Warehouse (SDW)/VBA

From ReliaWiki
Jump to navigation Jump to search
APIWiki.png



Tutorial: Transfer Data from an Excel File to the SDW

Below is the VBA version of the tutorial.

VBA
 
Sub Main()

 'Declare a new RawDataSet object. 
  Dim DataCollection As New RawDataSet

 'Name it "New Data Collection," and then specify that 
 'it is for use with Weibull++. 
  DataCollection.ExtractedName = "New Data Collection"
  DataCollection.ExtractedType = RawDataSetType_Weibull

 'Declare a RawData object. 
  Dim Row As RawData

 'Read each row of data from the Excel sheet. 
  Dim i As Integer, MaxRow As Integer
  MaxRow = 20

  For i = 2 to MaxRow
      Set Row = New RawData

     'Set the properties for the current data point. 
      Row.StateFS = Sheet1.Cells(i, 1)
      Row.StateTime = Sheet1.Cells(i,2)
      Row.FailureMode = Sheet1.Cells(i,3)

     'Add the current data point to the data collection. 
      Call DataCollection.AddDataRow(Row)
  Next i

 'Connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToRepository ("C:\RSRepository1.rsr11")  'Replace with name and path to test repository. 

 'Send the data collection to the repository. 
  Call MyRepository.DataWarehouse.SaveRawDataSet(DataCollection)

End Sub