Topic
5 replies Latest Post - ‏2013-01-11T16:40:10Z by SystemAdmin
SystemAdmin
SystemAdmin
1061 Posts
ACCEPTED ANSWER

Pinned topic How to use VBA to change Definition Name

‏2013-01-10T18:37:27Z |
I am attempting to change the name of a definition using the following code, but it seems to be ignoring the command:

myDefinition.SetProperty "Name", "NEW NAME"
myDefinition.Save

Any thoughts?
Updated on 2013-01-11T16:40:10Z at 2013-01-11T16:40:10Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1061 Posts
    ACCEPTED ANSWER

    Re: How to use VBA to change Definition Name

    ‏2013-01-10T19:21:11Z  in response to SystemAdmin
    The .name attribute is readonly; but can be changed using the ISAImf methods. Use the SA.Application object to read the definition to get the ddid. Then use the ddid of the definition to open, update, and save the definition via the ISAImf interface.

    Example using a 'test' definition of type BPMN Process:

    Dim sa As SA2001.Application
    Dim saobjects As saobjects
    Dim saDef As SA2001.Definition
    Dim saIMF As SA2001.ISAImf
    Dim defHandle As Long
    Dim defDDID As Long
    Dim saErr As Long

    Set saIMF = sa.Interface("ISAImf")

    Set saobjects = sa.Encyclopedia.GetFilteredDefinitions("*", 603)
    saobjects.ReadAll

    For i = 1 To saobjects.Count
    Set saDef = saobjects(i)
    If saDef.name = "Test" Then
    saIMF.SAOpenDefinition saDef.ddId, defHandle
    saErr = saIMF.SASetDefinitionName(defHandle, "New Name")
    If saErr = 0 Then
    saIMF.SASaveDefinition defHandle, defDDID
    Else
    MsgBox saErr 'put error handling here
    End If
    End If
    Next
  • SystemAdmin
    SystemAdmin
    1061 Posts
    ACCEPTED ANSWER

    Re: How to use VBA to change Definition Name

    ‏2013-01-10T19:21:37Z  in response to SystemAdmin
    The ".name" attribute is readonly; but can be changed using the ISAImf methods. Use the SA.Application object to read the definition to get the ddid. Then use the ddid of the definition to open, update, and save the definition via the ISAImf interface.

    Example using a 'test' definition of type BPMN Process:

    Dim sa As SA2001.Application
    Dim saobjects As saobjects
    Dim saDef As SA2001.Definition
    Dim saIMF As SA2001.ISAImf
    Dim defHandle As Long
    Dim defDDID As Long
    Dim saErr As Long

    Set saIMF = sa.Interface("ISAImf")

    Set saobjects = sa.Encyclopedia.GetFilteredDefinitions("*", 603)
    saobjects.ReadAll

    For i = 1 To saobjects.Count
    Set saDef = saobjects(i)
    If saDef.name = "Test" Then
    saIMF.SAOpenDefinition saDef.ddId, defHandle
    saErr = saIMF.SASetDefinitionName(defHandle, "New Name")
    If saErr = 0 Then
    saIMF.SASaveDefinition defHandle, defDDID
    Else
    MsgBox saErr 'put error handling here
    End If
    End If
    Next
    • SystemAdmin
      SystemAdmin
      1061 Posts
      ACCEPTED ANSWER

      Re: How to use VBA to change Definition Name

      ‏2013-01-10T19:34:13Z  in response to SystemAdmin
      Thanks Phil - I'll give this a try. Are there any other places where the ISAImf interface is documented? I've seen it used in other examples, and have used it without knowing much about it.
      • SystemAdmin
        SystemAdmin
        1061 Posts
        ACCEPTED ANSWER

        Re: How to use VBA to change Definition Name

        ‏2013-01-10T20:17:42Z  in response to SystemAdmin
        I have never found any doc on it.
        • SystemAdmin
          SystemAdmin
          1061 Posts
          ACCEPTED ANSWER

          Re: How to use VBA to change Definition Name

          ‏2013-01-11T16:40:10Z  in response to SystemAdmin
          It works like a charm - thank you!