Thanks Jon & Jan,
I am using MicroStation v0.04.00.46, and have an Item Property called ShrubsGrasses with a property definition called ComonName
I played around with it a bit more and eventually got it to work, so YES you can edit Items with VBA.
Sub TEST_Item_Modify()
If False = ActiveModelReference.AnyElementsSelected Then Exit Sub ' No elements to modify..
Dim oEE As ElementEnumerator, sPropertyName As String, sPropertyValue As String
Set oEE = ActiveModelReference.GetSelectedElements
sPropertyName = "ShrubsGrasses.ComonName" ' Property to find
sPropertyValue = "Violet" ' Value to compare and set to
Do While oEE.MoveNext
Dim oPH As PropertyHandler
Set oPH = CreatePropertyHandler(oEE.Current)
If oPH.SelectByAccessString(sPropertyName) Then
If oPH.GetDisplayString <> sPropertyValue Then
Debug.Print sPropertyName & "[Before]: " & oPH.GetDisplayString
oPH.SetValue (sPropertyValue)
Debug.Print sPropertyName & "[After]: " & sPropertyValue
End If
End If
Loop
End Sub
I am using MicroStation v0.04.00.46, and have an Item Property called ShrubsGrasses with a property definition called ComonName
I played around with it a bit more and eventually got it to work, so YES you can edit Items with VBA.
Sub TEST_Item_Modify()
If False = ActiveModelReference.AnyElementsSelected Then Exit Sub ' No elements to modify..
Dim oEE As ElementEnumerator, sPropertyName As String, sPropertyValue As String
Set oEE = ActiveModelReference.GetSelectedElements
sPropertyName = "ShrubsGrasses.ComonName" ' Property to find
sPropertyValue = "Violet" ' Value to compare and set to
Do While oEE.MoveNext
Dim oPH As PropertyHandler
Set oPH = CreatePropertyHandler(oEE.Current)
If oPH.SelectByAccessString(sPropertyName) Then
If oPH.GetDisplayString <> sPropertyValue Then
Debug.Print sPropertyName & "[Before]: " & oPH.GetDisplayString
oPH.SetValue (sPropertyValue)
Debug.Print sPropertyName & "[After]: " & sPropertyValue
End If
End If
Loop
End Sub