Transfer Data to the Synthesis Data Warehouse (SDW)/VBA: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
(Created page with '{{Template:API}} ==Tutorial: Transfer Data from an Excel File to the SDW== Below is the VBA version of the tutorial. ''…')
 
No edit summary
 
Line 37: Line 37:
  {{APIComment|'Connect to a Synthesis repository.}}
  {{APIComment|'Connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}}) {{APIComment|'Replace with name and path to test repository.}}
   MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr11"}}) {{APIComment|'Replace with name and path to test repository.}}
   
   
  {{APIComment|'Send the data collection to the repository.}}
  {{APIComment|'Send the data collection to the repository.}}

Latest revision as of 18:29, 3 April 2017

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