Edit Existing Synthesis Resources/VBA: Difference between revisions
		
		
		
		Jump to navigation
		Jump to search
		
Kate Racaza (talk | contribs)  Created page with '{{Template:API}}  ==Tutorial: Edit an Existing Synthesis Resource== Below is the VBA version of the tutorial.    '''VBA'''    Sub Main()    …'  | 
				Kate Racaza (talk | contribs) No edit summary  | 
				||
| (One intermediate revision by the same user not shown) | |||
| Line 10: | Line 10: | ||
  {{APIComment|'Connect to a Synthesis repository and project.}}  |   {{APIComment|'Connect to a Synthesis repository and project.}}  | ||
    {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository  |     {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository  | ||
    MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.  |     MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr11"}}){{APIComment|'Replace with name and path to test repository.}}  | ||
    MyRepository.Project.SetCurrentProject(1){{APIComment|'Replace with the object ID of test project.}}  |     MyRepository.Project.SetCurrentProject(1){{APIComment|'Replace with the object ID of test project.}}  | ||
| Line 16: | Line 16: | ||
    {{APIPrefix|Dim}} Amodel {{APIPrefix|As New}} cModel  |     {{APIPrefix|Dim}} Amodel {{APIPrefix|As New}} cModel  | ||
  {{APIComment|'Retrieve a model from the   |   {{APIComment|'Retrieve a model from the project.}}  | ||
    {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(21){{APIComment|'Replace with the object ID of test model.}}  |     {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(21){{APIComment|'Replace with the object ID of test model.}}  | ||
 {{APIComment|'Edit the model's name, description and part number.}}  | |||
    Amodel.Name = {{APIString|"MyNewModel_Updated"}}  |     Amodel.Name = {{APIString|"MyNewModel_Updated"}}  | ||
    Amodel.ItemDescription = {{APIString|"A specific type of light bulb."}}  |     Amodel.ItemDescription = {{APIString|"A specific type of light bulb."}}  | ||
    Amodel.ItemPartNumber = {{APIString|"PN5461"}}      |     Amodel.ItemPartNumber = {{APIString|"PN5461"}}      | ||
  {{APIComment|'Send the changes to the   |   {{APIComment|'Send the changes to the project.}}  | ||
    {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)  |     {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)  | ||
  End Sub  |   End Sub  | ||
Latest revision as of 18:16, 3 April 2017
![]()  | 
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
