Connect or Disconnect from a Synthesis Repository/VBA

From ReliaWiki
Revision as of 23:35, 26 April 2016 by Kate Racaza (talk | contribs) (Created page with '{{Template:API}} ==Tutorial: Connect and Disconnect from a Synthesis Repository== Below is the VBA version of the tutorial. …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.rsr10" exists in the C drive. 
  MyRepository.ConnectToRepository("C:\RSRepository1.rsr10")

 '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