Copy Text Fields

C

CB

I originally posted this in the general questions area. Jan De Messemaeker
responded stating that this was some oddity of Proj 2007. Jan also posted
some code which I could not get to work either.

I use the custome text fields for information that I need to share with the
task and the assignment fields. Please someone help me.

Original post:
I am using MSOP 2007. I am trying to get the gantt view text 2 field copied
to the resource text 2 field. Any ideas on what is wrong here. I have used
this in MSP 2002 without any problems.


Sub PortfromGantttoResource()

Dim t As Task
Dim ts As Tasks
Dim A As Assignment
Set ts = ActiveProject.Tasks
For Each t In ts
If Not t Is Nothing Then
For Each A In t.Assignments
A.Text2 = t.Text2
Next A
End If
Next t
End Sub

I am trying to get the gantt view text 2 field copied to the resource text
2 field. Any ideas on what is wrong here. I have used this in MSP 2002
without any problems.
 
J

JulieS

Hello CB,

Just a quick point to clarify. Are you trying to get information you
entered in the Text2 field in the Gantt chart view to show up on the
**assignment line** in the Task Usage view? The code that you have
copies task text2 data to assignment text2 field -- not the resource
text 2 field. I believe Jan's code copies the data to the resource
text2 field.

If you want to take information you entered into the Text2 field
showing in a Gantt chart view and add the same data to the assignment
rows for that task, no code is needed. Select the Text2 field, and
choose Tools > Customize, Fields in the menu. In the Custom Fields
dialog box, select "Roll down unless manually entered" under
"Calculation for assignment rows."
--
I hope this helps. Let us know how you get along.

Julie
Project MVP

Visit http://project.mvps.org/ for the FAQs and additional information
about Microsoft Project
 
C

CB

Hi Julie,
This will pull the data to the Task Usage view. I want to pull the
information over and display in the resource sheet and resource usage views.
What am I missing?
CB
 
J

JulieS

Thanks for the additional information and clarification, CB. As Jan
noted in his original reply, Project 2007 has changed the way
assignment data is structured.

In earlier releases, if you copied information from the Task Text2 to
the assignment Text2 for that task using the code you noted, you could
then add the Text2 field to the Resource Usage view the assignment
would show the same data. In project 2007 there are different
resource/assignment fields and task/assignment fields.

That being said, I ran Jan's code and it copied Text2 data from the
Task Text2 to the Task/Assignment Text2 field and then to the
Resource/Assignment Text2 field. If I add the Text2 field to both the
Task Usage and the Resource Usage view, it is correctly populated.
The data is *not* populated to the Resource line visible in the
Resource Sheet view. I can image a conflict if a resource had several
assignments with different data in Text2 -- which Text2 data would
appear?

Perhaps if you could state more clearly what is *not* working when you
run the code. What error messages appear.

I hope this helps. Let us know how you get along.

Julie
Project MVP

Visit http://project.mvps.org/ for the FAQs and additional information
about Microsoft Project
 
J

Jan De Messemaeker

First, *Thanks* for the confidence: why crosspost? Do you really think this
NG has different specialists?
Another thing: don't invent things that aren't tru.
Your code DOES NOT, that is NOT AT ALL, copy a task field to the resource
sheet. NOT.
So when I complete it you cannot hope that suddenly it will.
Greetings,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
C

CB

First of all let's get the P back in MVP. Secondly, I am on the news group
enough to know that the same folks are on all MSP NGs.

As for your next comment, the code DID...THAT IS DID WORK in 02.

As for 2007, Guess I will just have to find a work around. This always seem
to be the case when an upgrade is released.
 
C

CB

Thanks Julie. This helps.

JulieS said:
Thanks for the additional information and clarification, CB. As Jan
noted in his original reply, Project 2007 has changed the way
assignment data is structured.

In earlier releases, if you copied information from the Task Text2 to
the assignment Text2 for that task using the code you noted, you could
then add the Text2 field to the Resource Usage view the assignment
would show the same data. In project 2007 there are different
resource/assignment fields and task/assignment fields.

That being said, I ran Jan's code and it copied Text2 data from the
Task Text2 to the Task/Assignment Text2 field and then to the
Resource/Assignment Text2 field. If I add the Text2 field to both the
Task Usage and the Resource Usage view, it is correctly populated.
The data is *not* populated to the Resource line visible in the
Resource Sheet view. I can image a conflict if a resource had several
assignments with different data in Text2 -- which Text2 data would
appear?

Perhaps if you could state more clearly what is *not* working when you
run the code. What error messages appear.

I hope this helps. Let us know how you get along.

Julie
Project MVP

Visit http://project.mvps.org/ for the FAQs and additional information
about Microsoft Project
 
O

Oleg

Hello!
An another question on copying text fields...
This macro copies text fields from gannt to resource usage:
Public Sub TaskToResource()
Dim t As Task
Dim r As Resource
Dim a As Assignment
On Error Resume Next

Dim pj As Project
Set pj = Application.ActiveProject


For Each t In pj.Tasks
For Each r In t.Resources
For Each a In r.Assignments

If t.Name = a.TaskName Then

a.Text6 = t.Text6
a.Text10 = t.Text10

End If

Next a
Next r
Next t

My problem is, that if the task name occures repeatedly, the text field
content of the first task is copied to all associated text fields on resource
usage.
Do you see possibilty to solve this problem?
Thank you!
Kind regards,
Oleg
 
J

John

Oleg said:
Hello!
An another question on copying text fields...
This macro copies text fields from gannt to resource usage:
Public Sub TaskToResource()
Dim t As Task
Dim r As Resource
Dim a As Assignment
On Error Resume Next

Dim pj As Project
Set pj = Application.ActiveProject


For Each t In pj.Tasks
For Each r In t.Resources
For Each a In r.Assignments

If t.Name = a.TaskName Then

a.Text6 = t.Text6
a.Text10 = t.Text10

End If

Next a
Next r
Next t

My problem is, that if the task name occures repeatedly, the text field
content of the first task is copied to all associated text fields on resource
usage.
Do you see possibilty to solve this problem?
Thank you!
Kind regards,
Oleg

Greg,
Yes, fix your project file so that no two task names are identical.
Point of fact, if two tasks have an identical task description then
those tasks are in fact the same task.

Unfortunately I find that many users try to shortcut task descriptions
just as you describe. This leads to several issues, incomplete
description of the true task intent, confusion when filtering, problems
with simple macros (in your case), confusion when sorting, etc.

OK, that's the real "fix" for your problem. However on the off chance
that you don't like my opening suggestion, set a flag in the innermost
loop so the current text data is only written once.

John
Project MVP
 

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