属性ドメインの更新

theMacro()

Dim pFW As IWorkspaceFactory
'Set pFW = New AccessWorkspaceFactory
Set pFW = New SdeWorkspaceFactory
'Set pFW = New FileGDBWorkspaceFactory


Dim strPath As String
strPath = "C:\Documents and Settings\Administrator\Application Data\ESRI\ArcCatalog\"
'strPath = "D:\Workspace\New File Geodatabase.gdb"

Dim strDB As String
'strDB = "Connection to cs-sde.sde"
strDB = "ZEKE_EXPRESS.sde"
'strDB = "ZEKE.sde"

Dim pWorkspace As IWorkspaceEdit
Set pWorkspace = pFW.OpenFromFile(strPath & strDB, 0)

Dim lng As Long
lng = 2

remove_Code pWorkspace, "test", lng


End Sub

' from IICodedValueDomain::DeleteCode Example in VBA Help
Function remove_Code(pWorkspace As IWorkspace, sName As String, sVal As Variant)
   
   Dim pWSDomains As IWorkspaceDomains2
   Set pWSDomains = pWorkspace
 
   Dim pDomain As IDomain
   Set pDomain = pWSDomains.DomainByName(sName)
 
   If pDomain.Type <> esriDTCodedValue Then
     Exit Function
   End If
   
   Dim pCodedValueDomain As ICodedValueDomain
   Set pCodedValueDomain = pDomain
   
   pCodedValueDomain.DeleteCode sVal
   pCodedValueDomain.AddCode sVal + 20, "test"
   pWSDomains.AlterDomain pCodedValueDomain
   
End Function