Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2003
    Location
    Indianapolis, Indiana, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to Toggle Leveling (Automatic:=True/False) (Project 2002)

    Greetings, I can't believe this was not an easy task, but I tried using the macro recorder to create some code to toggle
    LevelingOptions Automatic:=True / False
    I tried using an IF statement, but I was unsuccesful with any-&-all efforts with the syntax. I'm by no means an expert at either Project or writing macros, but I didn't think this would be too tough. I'd hoped also to create a button whose name or image would change along with the active option. But I'd be happy with just attaching a keyboard shortcut...

    I'd appreciate any help. Thanks!

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Macro to Toggle Leveling (Automatic:=True/False) (Project 2002)

    Could you please post your code.
    Regards,

    Gary
    (It's been a while!)

  3. #3
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Macro to Toggle Leveling (Automatic:=True/False) (Project 2002)

    Leveling is set using the Leveling Options Method as follows: expression.LevelingOptions(Automatic, DelayInSlack, AutoClearLeveling, Order, LevelEntireProject, FromDate, ToDate, PeriodBasis, LevelIndividualAssignments, LevelingCanSplit)

    You can set the leveling options automatic to true as LevelingOptions True in your code or False to turn it back off.

    ... or you could try some code like this to do the leveling...

    Sub LevelResourcesInSelectedTasks()

    Dim T As Task ' Task object used in For Each loop
    Dim A As Assignment ' Assignment object used in For Each loop

    For Each T In ActiveSelection.Tasks
    For Each A In T.Assignments
    If ActiveProject.Resources(A.ResourceID).Overallocate d Then
    ActiveProject.Resources(A.ResourceID).Level
    End If
    Next A
    Next T

    End Sub


    Just be careful and make sure you understand all of the leveling options before doing this. I know leveling can be a big help on projects, but, when not used correctly, can cause a lot of problems as well. Make sure you save your project before trying this.

    HTH
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •