D
De Smet Marc
In Project I added a new column "Number of Resources". VBA is used Event Programming and I have an EvenClassModule with the following code
Private Sub App_ProjectAssignmentNew(ByVal pj As Project, ByVal ID As Long)
ActiveCell.Task.Number2 = ActiveCell.Task.Assignments.Count
End Sub
Problems:
- when a new task is inserted somewhere between existing tasks, a blank row appears and my function generates the run time error '91' Object variable or With block variable not set. I assume this is because although a blank row is created by Project, as task has not yet been created
- when adding resources on an existing task, e.g. adding 3 different resources, my function is called 4 times, but Number2 contains 2 (it always contains 1 less than the real number of resources).
- when removing a resource name from the column "Resource Names" (or from the edit bar just above the cells) my function is not called at all.
Questions:
- How to avoid this function to run with a 'new' task (one which has not yet a task name
- What to do to get the right count (should I simple add 1: will that always work correctly?)
- How to get the function being called when directly editing the resource names (not going through Task Information)
Lots of thanks for the person(s) how can help me here.
Kind regards
Marc
Private Sub App_ProjectAssignmentNew(ByVal pj As Project, ByVal ID As Long)
ActiveCell.Task.Number2 = ActiveCell.Task.Assignments.Count
End Sub
Problems:
- when a new task is inserted somewhere between existing tasks, a blank row appears and my function generates the run time error '91' Object variable or With block variable not set. I assume this is because although a blank row is created by Project, as task has not yet been created
- when adding resources on an existing task, e.g. adding 3 different resources, my function is called 4 times, but Number2 contains 2 (it always contains 1 less than the real number of resources).
- when removing a resource name from the column "Resource Names" (or from the edit bar just above the cells) my function is not called at all.
Questions:
- How to avoid this function to run with a 'new' task (one which has not yet a task name
- What to do to get the right count (should I simple add 1: will that always work correctly?)
- How to get the function being called when directly editing the resource names (not going through Task Information)
Lots of thanks for the person(s) how can help me here.
Kind regards
Marc