Topic
No replies
TerryMoriarty
TerryMoriarty
126 Posts
ACCEPTED ANSWER

Pinned topic Rename Attributes in VBA

‏2013-03-18T18:27:57Z |
I want to rename attributes in VBA. I found a macro here and used it to rename entities. Worked just fine. But doesn't work for attributes because it opens the definition edit window and you can't open an attribute's edit window directly. So, I get the message about having to open it's entity and everything stops working. Just goes on to the next attribute to be renamed without doing anything.

The relevant code that I copied is:
For Each clsDDID In clnDDIDs
With clsDDID
strName = Replace(.Name, " ", "_")
Call imfSA.SAEditDefinition(.ddId, 0) ' 0 = Open as Read/Write
Call imfSA.SARenameDefinition(.ddId, strName) ' Update and Close
Call clsDDID.Save
End With
Next

I tried the following to replace the SAEditDefinition statement, but got a "method or data member not found" compile error on the Call CurDef.ReadAll statement.

Dim CurDef As SA2001.Definition

For Each clsDDID In clnDDIDs
With clsDDID
strName = Replace(.Name, " ", "_")

' want to avoid using this stmt Call imfSA.SAEditDefinition(.ddId, 0) ' 0 = Open as Read/Write

Set CurDef = appSA.Encyclopedia.GetDefinitionById(clsDDID.ddId)
Call CurDef.ReadAll
Call imfSA.SARenameDefinition(.ddId, strName) ' Update and Close
Call CurDef.Save
End With
Next

I'm hoping that I'm missing something very obvious, but right now, I can't see it.

Thanks,
Terry