485 error

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
 
S

Stephen Sanderlin

This is a known bug which was fixed in KB941657 (the Post-SP1 Hotfix
Rollup): http://support.microsoft.com/kb/941657



From the article:

You receive error 458 when you try to save or import a Project plan that
uses the ProjectBeforeTaskChange event or the ProjectBeforeTaskChange2
event

You are using a Project plan that contains a macro that uses the
ProjectBeforeTaskChange event or the ProjectBeforeTaskChange2 event. You
try to do one of the following tasks:

..

You click Save on the File menu to name the Project plan, and then you
try to save the Project plan.

..

You try to import the Project plan to the enterprise resource pool by
using the Import Wizard.

In this scenario, you receive the following error message:

Error 458: Variable uses an automation type not supported in Visual
Basic.



I do not, however, know why you are getting Error 485. it should be 458.



Error Handling in VBA is discussed here:
http://www.cpearson.com/excel/ErrorHandling.htm


--

Stephen Sanderlin

Principal Consultant

MSProjectExperts



For Project Server Consulting: http://www.msprojectexperts.com

For Project Server Training: http://www.projectservertraining.com



Read my blog at: http://www.projectserverhelp.com/

Join the community at: http://forums.epmfaq.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top