Connect or Disconnect from a Synthesis Repository/VBA: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
(Created page with '{{Template:API}} ==Tutorial: Connect and Disconnect from a Synthesis Repository== Below is the VBA version of the tutorial. …')
 
(Updated for V11)
 
Line 11: Line 11:
    
    
  {{APIComment|'Specify the full path to the standard repository. Assume that}}
  {{APIComment|'Specify the full path to the standard repository. Assume that}}
  {{APIComment|'a standard repository called "RSRepository1.rsr10" exists in the C drive.}}
  {{APIComment|'a standard repository called "RSRepository1.rsr11" exists in the C drive.}}
   MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr10"}})
   MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr11"}})
   
   
  {{APIComment|'Declare a new NameIdPair object.}}
  {{APIComment|'Declare a new NameIdPair object.}}

Latest revision as of 18:01, 3 April 2017

APIWiki.png


Tutorial: Connect and Disconnect from a Synthesis Repository

Below is the VBA version of the tutorial.

VBA
 
Sub Main()

 'Declare a new Repository object. 
  Dim MyRepository As New Repository
 
 'Specify the full path to the standard repository. Assume that 
 'a standard repository called "RSRepository1.rsr11" exists in the C drive. 
  MyRepository.ConnectToRepository("C:\RSRepository1.rsr11")

 'Declare a new NameIdPair object. 
  Dim ListofProjects() As NameIdPair

 'Get a list of all projects in the repository. 
  ListOfProjects = MyRepository.Project.GetAllProjects

 'Set the first available project as the current project. 
  MyRepository.Project.SetCurrentProject(ListofProjects(0).ID)

 'Display the name and object ID of the current project. 
  Dim ProjectName As String
  Dim ProjectID As Integer 

  ProjectName = MyRepository.Project.GetCurrentProject.Name
  ProjectID = MyRepository.Project.GetCurrentProject.ID
  MsgBox ("You are currently connected to: " & ProjectName & ", ID#" & ProjectID)

 'Disconnect from the Synthesis repository. 
  MyRepository.DisconnectFromRepository

End Sub