Connect or Disconnect from a Synthesis Repository/VBA

From ReliaWiki
Jump to navigation Jump to search
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