Edit Existing Synthesis Resources/VBA

From ReliaWiki
Jump to navigation Jump to search
APIWiki.png



Tutorial: Edit an Existing Synthesis Resource

Below is the VBA version of the tutorial.

VBA

Sub Main()

 'Connect to a Synthesis repository and project. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToRepository("C:\RSRepository1.rsr11") 'Replace with name and path to test repository. 
  MyRepository.Project.SetCurrentProject(1) 'Replace with the object ID of test project. 

 'Declare a new cModel object. 
  Dim Amodel As New cModel
 
 'Retrieve a model from the project. 
  Set AModel = MyRepository.Model.GetModel(21) 'Replace with the object ID of test model. 

 'Edit the model's name, description and part number. 
  Amodel.Name = "MyNewModel_Updated"
  Amodel.ItemDescription = "A specific type of light bulb."
  Amodel.ItemPartNumber = "PN5461"   
 
 'Send the changes to the project. 
  Call MyRepository.Model.UpdateModel(AModel)

End Sub