J
Jose X Perez
Hi everyone,
I'm new in VBA so maybe it is a dumb question.
I install project server 2007 enviroment and for a task field that need a
especial calculation, create a macro. that i copy in the post.
Dim X As New Class1
Private Sub Project_Open(ByVal pj As Project)
Set X.App = Application
End Sub
----class1
Public WithEvents App As Application
Private Sub App_ProjectBeforeTaskChange(ByVal t As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
'When a task is updated check that the updated field is "value"
'if the otuline level of the task is 1 it calculates "value"*"project value"
for the field "conditional value"
'if not it takes the "conditional value" of the parent task and muliply it
for "value" of the task
Dim condValueTemp As Double
If Field = FieldNameToFieldConstant("value", pjTask) Then
If t.OutlineLevel = 1 Then
condValueTemp = NewVal *
ActiveProject.ProjectSummaryTask.GetField(FieldNameToFieldConstant("project
value")) / 100
Call t.SetField(FieldNameToFieldConstant("conditional value"),
pesoPonderadoTemp)
Else
condValueTemp = NewVal *
t.OutlineParent.GetField(FieldNameToFieldConstant("conditional value",
pjTask)) / 100
Call t.SetField(FieldNameToFieldConstant("conditional value"),
pesoPonderadoTemp)
End If
End If
End Sub
It makes the correct calculation but when i save the proyect for the first
time to the project server i get the error
run-time error '485': variable uses an Automation type not supported in
Visual Basic
and when i click debug in the dialog
it points me to this line
Private Sub App_ProjectBeforeTaskChange(ByVal t As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
The quiestions are,
what could be the error?
how can i get a better code?
is there a way to catch the error and not show it to the user?
Thanks for your help,
Jose X Perez
I'm new in VBA so maybe it is a dumb question.
I install project server 2007 enviroment and for a task field that need a
especial calculation, create a macro. that i copy in the post.
Dim X As New Class1
Private Sub Project_Open(ByVal pj As Project)
Set X.App = Application
End Sub
----class1
Public WithEvents App As Application
Private Sub App_ProjectBeforeTaskChange(ByVal t As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
'When a task is updated check that the updated field is "value"
'if the otuline level of the task is 1 it calculates "value"*"project value"
for the field "conditional value"
'if not it takes the "conditional value" of the parent task and muliply it
for "value" of the task
Dim condValueTemp As Double
If Field = FieldNameToFieldConstant("value", pjTask) Then
If t.OutlineLevel = 1 Then
condValueTemp = NewVal *
ActiveProject.ProjectSummaryTask.GetField(FieldNameToFieldConstant("project
value")) / 100
Call t.SetField(FieldNameToFieldConstant("conditional value"),
pesoPonderadoTemp)
Else
condValueTemp = NewVal *
t.OutlineParent.GetField(FieldNameToFieldConstant("conditional value",
pjTask)) / 100
Call t.SetField(FieldNameToFieldConstant("conditional value"),
pesoPonderadoTemp)
End If
End If
End Sub
It makes the correct calculation but when i save the proyect for the first
time to the project server i get the error
run-time error '485': variable uses an Automation type not supported in
Visual Basic
and when i click debug in the dialog
it points me to this line
Private Sub App_ProjectBeforeTaskChange(ByVal t As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
The quiestions are,
what could be the error?
how can i get a better code?
is there a way to catch the error and not show it to the user?
Thanks for your help,
Jose X Perez