![]() |
Telelogic System Architect (steve huntington) | ![]() |
Topic Title: change definition's propertys via VBA? Topic Summary: Created On: 30-Jul-2008 08:20 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hi,all.
I want to change the definition's property via VBA. The text property can be modified by function SetProperty("PropertyName" , "Value"). But , the property with control "combobox" , I can not change its property value. if I use the function "SetProperty", its value can be changed , I can get it via the funciton "GetProperty" , but can not be displayed. for example , In the sample encyclopedia , in the system type definition , the definition "Hotel Booking System", its "Related SBBs" property is mulity values "combobox", I can not change its values. How should I do ,please? Thanks. |
|
![]() |
|
![]() |
|
As far as I am aware that should work. I have a macro built for us by a Popkin consultant (so its been working fine for years) which uses:
Call defDefinition.SetProperty(gstrProperty, strPropertyValue) as a generic for adding a value to any field. I would suggest double checking the spelling of the values that you are adding to make sure that they are permitted values. Also check for quotes, are you inserting them when not needed or omitting them when needed? |
|
![]() |
|
![]() |
|
I think you are referring to a property that is a "List Of". In that case you need to use the ofCollection class because the list is a collection of objects. This is very well documented in the VBA extensibility guide.
Here is small example of how you might add an item to the list and read thru the list. Dim SAapp As SA2001.Application Dim defs As SA2001.SAObjects Dim def As SA2001.Definition Dim coll as ofCollection, idx as Long Set SAapp = New SA2001.Application Set defs = SAapp.Encyclopedia.GetFilteredDefinitions("", DFXAPPLICATION) defs.ReadAll Set def = defs.Item(1) Set coll = def.GetPropertyAsCollection("Technology") 'add item to collection coll.Add (Chr(34) & "New Item" & Chr(34)) coll.SetProperty def.save 'read thru collection For idx = 1 To coll.Count debug.print coll.item(idx).name next idx |
|
![]() |
|
![]() |
|
thanks.
Now I can add data to "listOf". Buf I want to know , the element of "listOf", if the data I want to add is the in one of the elements ,I add it ,if not , do not add. How should I get the elements of "listof"? |
|
![]() |
|
![]() |
|
That is done in the last few lines.
Here is a mere re-arrangement of excellent example supplied by Elvin. part 1: get the list of elements part 2: loop through the listof elements part 3: add item to listof Dim SAapp As SA2001.Application Dim defs As SA2001.SAObjects Dim def As SA2001.Definition Dim coll as ofCollection, idx as Long Set SAapp = New SA2001.Application Set defs = SAapp.Encyclopedia.GetFilteredDefinitions("", DFXAPPLICATION) defs.ReadAll Set def = defs.Item(1) Set coll = def.GetPropertyAsCollection("Technology") 'read thru collection - elements of listof For idx = 1 To coll.Count debug.print coll.item(idx).name next idx 'add item to collection coll.Add (Chr(34) & "New Item" & Chr(34)) coll.SetProperty def.save |
|
![]() |
|
![]() |
|
If you want to automatically check if a name exists then you do that by adapting the section
'read thru collection - elements of listof For idx = 1 To coll.Count debug.print coll.item(idx).name next idx Assign the new name to a variable, lets say strNewName Create a boolean indicator to show if the item is found, lets call it bIndicator bIndicator = False 'read thru collection - elements of listof For idx = 1 To coll.Count if coll.item(idx).name = strNewName then bIndicator = True end if next idx You then perform the section "add item to collection" only if bIndicator is True. |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.