I am creating a ton of packages and a ton of requirements, even a bunch of views in my VB code. How can I check if these packages already exist, with the same name of course. Right now I'm going through creating all the packages, but if one of those packages already exists, like the first one for example, it throws an error. Would it be best to just have it skip the error and move on? If so, could you show a good way to do that.
NASA - KSC
This topic has been locked.
1 reply Latest Post - 2010-12-06T20:51:31Z by EdwardOverton
Pinned topic Checking if a Package or Requirement Exists before Creation
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2010-12-06T20:51:31Z at 2010-12-06T20:51:31Z by EdwardOverton
EdwardOverton 060000MGKW3 PostsACCEPTED ANSWER
Re: Checking if a Package or Requirement Exists before Creation2010-12-06T20:51:31Z in response to Xystus777‘ The follow code is a snippet of code you must connect to and open the project
‘ After this code you should close the project
Dim aProject As ReqPro40.Project
Dim aReqs As ReqPro40.Requirements
Dim aReqType As ReqPro40.ReqType
Dim aTag as String
' Attempt to retrieve requirement type of tag=aTag
' BR = Business Rules
aTag = "BR"
Set aReqs = aProject.GetRequirements(aTag, _
If aReqs Is Nothing Then
' requirement type does not exist
Set aReqType = aProject.ReqTypes.Add("sName", _
If Not aReqType Is Nothing Then
MsgBox "Requirement " & aTag & " already exists!"
' The bolded code can be replaced with
aReqType.Attrs.Add and the appropriate arg values - add attributes
ReqAttr.ListItems.Add and the appropriate arg values - add list of values
' See if a package exists, you have to know its key
Set aPackage = aProject.GetPackage(PackageKey, _
Hope this helps