locked
Resource Availability and VBA RRS feed

  • Question

  • 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

    Wednesday, September 5, 2018 5:18 PM

Answers

  • 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

    Thursday, September 6, 2018 5:27 AM

All replies

  • 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

    Thursday, September 6, 2018 5:27 AM
  • Thanks a lot Barbara, that's exactly what I need

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

    Thursday, September 6, 2018 9:31 AM