use macro in project server 2007

J

Jose X Perez

Hi everyone,
I'm trying to use a macro in project server in order to update a custom task
field.
But i do not know how to access the value of others defined task custom
fields.
the macro that works localy in mi pc is
Private Sub App_ProjectBeforeTaskChange(ByVal t As Task, _
ByVal Field As PjField, _
ByVal NewVal As Variant, _
Cancel As Boolean)
If Field <> pjTaskNumber2 Then
If t.Summary Or t.OutlineLevel = 1 Then
Rem MsgBox ("summary")
t.Number2 = t.Number1 * t.Number3 / 100
End If
If t.Summary And t.OutlineLevel > 1 Then
t.Number2 = t.Number1 * t.OutlineParent.Number2 / 100
End If
If Not t.Summary And t.OutlineLevel > 1 Then
Rem MsgBox ("not summary")
t.Number2 = t.Number1 * t.OutlineParent.Number2 / 100
End If
End If
End Sub


in order to make this works in the preject server i need to access the
taskCustomFieldNumber isntead of Number1

How can i do this? or i must use PSI ?
i preffer not to use PSI because i'll need to use a programer and i do not
have the resource.

thanks for your help
Jose X Perez
 
M

Martin Winzig

Following functionality is awailable from Project Pro 2007 Sp1,
Task properties are not strongly typed, but when you use custom property
name as task property it works.

Infortnately you can't use same charecter in property names as space . ....

dim t as task
.....
t.name_of_enterprise taskproperty="cccc"
 
R

Rod Gill

Hi,

To read Project Server 2007 custom fields use:

t.GetField(FieldNameToFieldConstant("Custom Field name"))

Spaces are fine
--

Rod Gill
Microsoft MVP for Project

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

Martin Winzig

Method GetField & SetField are not methot of object Task. (Project Pro 2007
with SP1)

So when they will be implemented spacess will be fine. but now space are not
fine.
 
J

Jack Dahlgren

What? You can certainly use GetField and SetField.

Here is a line of code which I posted earlier and which works fine:

dim tsk as task

Call tsk.SetField(FieldNameToFieldConstant("Publish"), "No")

GetField works just the same.

-Jack Dahlgren
 
R

Rod Gill

I have Project Pro 2007 SP1 and Getfield and Set field are methods of Task
(including Project Summary task) and Resource objects, but not Assignment
objects. Search for Getfield in the object browser and Help in VBE also says
this!

--

Rod Gill
Microsoft MVP for Project

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

Martin Winzig

You are right,


Task have methosd setField & GetField

Problem i mentioned are related to object assigment

The object assignments haven't this methosd setField & getField so when you
need update assignment property you have to use name of the custom property
as property of object assignment. And it's the reason why you can't use same
characters.
 
S

Stephen Sanderlin

Forgive me, but I'm having some trouble understanding you...

I think you're saying that you cannot use GetField() and SetField() on
Assignment objects...

You are correct... these methods do not exist for the Assignment
object... you need to use the field name. Unfortunately, it will not
work if there is a space in the text. There was an article on Project
Programmability about this in January... the link is here:

http://blogs.msdn.com/project_programmability/archive/2008/01/24/reading
-assignment-enterprise-custom-field-values-with-vba.aspx

I am not aware of any plans to implement GetField and SetField for
assignments.

--
Stephen Sanderlin
Owner/Founder - EPMFAQ
http://www.epmfaq.com/
http://forums.epmfaq.com/

EPM Solutions Architect / Principal Consultant - BT Professional
Services
http://bt.ins.com/

This electronic message, along with any information, advice, and
opinions it contains, are mine alone and are not representative of my
employer. All information is provided in "GOOD FAITH" and on an "AS IS"
basis only. I provide no presentations or warranties, express or
implied, including implied warranties of fitness for a particular
purpose, merchantability, title, and noninfringement. I strongly advise
you to extensively test any changes, workarounds, or techniques
described herein on a development system prior to implementation in a
production environment, and you are hereby notified that I bear no
responsibility whatsoever for any loss, harm, or otherwise negative
outcomes resulting from your actions, whether or not said actions were
a result of this electronic message, directly or indirectly.
 

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