Item Example
Sub Example_Item() ' This example lists the number of keys in the Standard ' layer key styles collection, and then lists the name of ' each layer key styles collection in the drawing. The example ' uses both the string and integer methods of specifying the ' index of an Item. Dim app As New AecBaseApplication Dim doc As AecBaseDocument Dim layerkeystyles As AecLayerKeyStyles Dim keystyle As AecLayerKeyStyle Dim msg As String app.Init ThisDrawing.Application Set doc = app.ActiveDocument ' Get the drawing's collection of layer key styles. Set layerkeystyles = doc.layerkeystyles msg = "Number of Layer Key Styles in this drawing is: " & layerkeystyles.Count & vbCrLf ' Get the standard layer key style, if it exists (it should!) On Error Resume Next Set keystyle = layerkeystyles.Item("Standard") ' List the number of keys in the Standard layer key style. If Err Then msg = msg & "Standard layer key style does not exist in this drawing" Err.Clear Else msg = "Standard layer key style contains " & keystyle.Keys.Count & " keys." & vbCrLf End If On Error GoTo 0 ' Loop through the layer key styles collection, listing the name ' of each layer key style in the collection. msg = msg & vbCrLf & "The layer key styles in this drawing are:" & vbCrLf For i = 0 To (layerkeystyles.Count - 1) msg = msg & " " & layerkeystyles.Item(i).Name & vbCrLf Next MsgBox msg, vbInformation, "Item Example"
End Sub