none
Resource Availability and VBA

    Pertanyaan

  • Hello,

    How can we read and then write the Resource Availability in the Resource Information dialog box, period by period?

    Thanks for your help.


    Gérard Ducouret [Project MVP], Certifié Project 70632, Certifié ITIL

    05 September 2018 17:18

Jawaban

  • Hi Gerard,

    is this what you are asking for?

    Sub ResAvailability()
    Dim R As Resource
    Dim P As Project
    Dim A As Availability
    Dim LastA As Availability
    Dim NewDate As Date
    
    Set P = ActiveProject
    
    'set startdate for new availablity
    NewDate = DateSerial(2018, 10, 1)
    
    For Each R In P.Resources
        For Each A In R.Availabilities
            MsgBox R.Name & " - " & A.AvailableFrom & " - " & A.AvailableTo & " - " & A.AvailableUnit
        Next A
        Set LastA = R.Availabilities(R.Availabilities.Count)
        LastA.AvailableTo = DateAdd("d", -1, NewDate)
        'For "AvailableUnit:=LastA.AvailableUnit * 0.9", just modify as required
        R.Availabilities.Add AvailableFrom:=NewDate, AvailableTo:=DateSerial(2149, 12, 31), AvailableUnit:=LastA.AvailableUnit * 0.9
    Next R
    
    End Sub
    

    Regards
    Barbara

    06 September 2018 5:27
    Moderator

Semua Balasan

  • Hi Gerard,

    is this what you are asking for?

    Sub ResAvailability()
    Dim R As Resource
    Dim P As Project
    Dim A As Availability
    Dim LastA As Availability
    Dim NewDate As Date
    
    Set P = ActiveProject
    
    'set startdate for new availablity
    NewDate = DateSerial(2018, 10, 1)
    
    For Each R In P.Resources
        For Each A In R.Availabilities
            MsgBox R.Name & " - " & A.AvailableFrom & " - " & A.AvailableTo & " - " & A.AvailableUnit
        Next A
        Set LastA = R.Availabilities(R.Availabilities.Count)
        LastA.AvailableTo = DateAdd("d", -1, NewDate)
        'For "AvailableUnit:=LastA.AvailableUnit * 0.9", just modify as required
        R.Availabilities.Add AvailableFrom:=NewDate, AvailableTo:=DateSerial(2149, 12, 31), AvailableUnit:=LastA.AvailableUnit * 0.9
    Next R
    
    End Sub
    

    Regards
    Barbara

    06 September 2018 5:27
    Moderator
  • Thanks a lot Barbara, that's exactly what I need

    Gérard Ducouret [Project MVP], Certifié Project 70632, Certifié ITIL

    06 September 2018 9:31