Error Message while running Macro

J

Jayalakshmi

Hi Gill,

Its showing error in 7th line(Tsk.EnterpriseCost1=0) of the below specified
code.

Sub Material_Cost()
Dim Tsk As Task
Dim Res As Resource
Dim Assgn As Assignment
For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then
Tsk.EnterpriseCost1 = 0
For Each Assgn In Tsk.Assignments
Set Res = ActiveProject.Resources(Assgn.ResourceID)
If Res.Type = pjResourceTypeMaterial Then
Tsk.EnterpriseCost1 = Tsk.EnterpriseCost1 + Assgn.Cost
End If
Next Assgn
End If
Next Tsk
End Sub

Help me wi th this.

Thanks & Regards,
Jaya
 
J

John

Jayalakshmi said:
Hi Gill,

Its showing error in 7th line(Tsk.EnterpriseCost1=0) of the below specified
code.

Sub Material_Cost()
Dim Tsk As Task
Dim Res As Resource
Dim Assgn As Assignment
For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then
Tsk.EnterpriseCost1 = 0
For Each Assgn In Tsk.Assignments
Set Res = ActiveProject.Resources(Assgn.ResourceID)
If Res.Type = pjResourceTypeMaterial Then
Tsk.EnterpriseCost1 = Tsk.EnterpriseCost1 + Assgn.Cost
End If
Next Assgn
End If
Next Tsk
End Sub

Help me wi th this.

Thanks & Regards,
Jaya

Jaya,
There is nothing wrong with your code. But, I assume you realize that it
will only work if you are using a professional version of Project (i.e.
Project 2003 Pro, Project 2007 Pro)

John
Project MVP
 
J

Jayalakshmi

Hi John,

Thanks for your reply.

I am using Project Pro 2003. In some project this macro is running correctly
& i am getting result in Enterprise Cost1 Field. In some of the Projects its
showing debug error(in Tsk.EnterpriseCost1=0).

Ok.Can you please tell me the procedure to create Macro globally in Project
Server?
I think i have done something wrong.

Thanks & Regards,
Jaya
 
R

Rod Gill

Can you confirm this is Project Server 2003 please?

If so, then make sure you have the latest service packs installed and In
Project Pro open the Enterprise Global file. Use the Organizer to copy
relevant Modules etc to the Enterprise Global, save and close. The macro
will now be available to all users when they next open Project.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com



Jayalakshmi said:
Hi John,

Thanks for your reply.

I am using Project Pro 2003. In some project this macro is running
correctly
& i am getting result in Enterprise Cost1 Field. In some of the Projects
its
showing debug error(in Tsk.EnterpriseCost1=0).

Ok.Can you please tell me the procedure to create Macro globally in
Project
Server?
I think i have done something wrong.

Thanks & Regards,
Jaya
 

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