Share via


Month Object, Months Collection Object

Year
Months
Month
Multiple objects

Represents a month or the months in a year. The Month object is a member of the Months collection.

Using the Month Object

Use Months(Index), where Index is the month index number, month name, or PjMonth constant, to return a single Month object. The following example counts the number of working days in each month of 2002 for each selected resource.

Dim R As Resource
Dim D As Integer, M As Integer, WorkingDays As Integer

For Each R In ActiveSelection.Resources()
    WorkingDays = 0
    With R.Calendar.Years(2002)
        For M = 1 To .Months.Count
            WorkingDays = 0
            For D = 1 To .Months(M).Days.Count
                If .Months(M).Days(D).Working = True Then
                    WorkingDays = WorkingDays + 1
                End If
            Next D
            MsgBox "There are " & WorkingDays & " working days in " & _
                .Months(M).Name & " for " & R.Name & "."
        Next M
    End With
Next R

Using the Months Collection

Use the Months property to return a Months collection. The following example counts the number of months in 2002.

ActiveProject.Calendar.Years(2002).Months.Count

Properties | Application Property | Calendar Property | Count Property | Days Property | Index Property | Item Property | Name Property | Parent Property | Shiftn Property | Working Property

Methods | Default Method

Parent Objects | Day Object, Days Collection Object | Year Object, Years Collection Object

Child Objects | Calendar Object, Calendars Collection Object | Day Object, Days Collection Object | Shift Object

See Also | Months Property