Count Property (Attachments Collection)

The Count property returns the number of Attachment objects in the collection. Read-only.

Syntax

objAttachColl.Count

Data Type

Long

Example

This code fragment stores in an array the names of all Attachment objects in the collection. It shows the Count and Item properties working together.

' from the sample function, TstDrv_Util_SmallCollectionCount 
' objAttachColl is an Attachments collection 
x = Util_SmallCollectionCount(objAttachColl) 
 
Function Util_SmallCollectionCount(objColl As Object) 
Dim strItemName(100) As String ' Names of objects in collection 
Dim i As Integer               ' loop counter 
    On Error GoTo error_actmsg 
    If objColl Is Nothing Then 
        MsgBox "Must supply a valid collection object as a parameter" 
        Exit Function 
    End If 
    If 0 = objColl.Count Then 
        MsgBox "No items in the collection" 
        Exit Function 
    End If 
    For i = 1 To objColl.Count Step 1 
        strItemName(i) = objColl.Item(i).Name 
        If 100 = i Then ' max size of string array 
            Exit Function 
        End If 
    Next i 
    ' error handling here... 
End Function