Below is code i found by MS that writes any entries in text1 for tasks to text 1 for resources and assignments.
What I need to do now is figure out how to set text1 for tasks = to the current active projects filename. For example a project file will be saved as a project reference number "CR0295". I would want it to loop through all the tasks in the project and first write this value (the file name minus the extension) in text1 and then run the code to update text 1 in resources and assignments. I've searched help and can't find a way to reference the active file name. I'm sure I'm probably looking in the wrong place but any help with this code is appreciated.
Sub UpdateAssignmentNumber()
'Variables for tracking current task and assignment
Dim oTask As Task
Dim oAssignment As Assignment
Dim oResource As Resource
'Looping through all tasks in the project
For Each oTask In ActiveProject.Tasks
'Checking to see if task is blank
If Not oTask Is Nothing Then
'Looping through each assignment for a task
For Each oResource In oTask.Resources
'Updating the number1 field for the assignment based on value
'at task level for the number1 field
oResource.Text1 = oTask.Text1
'Processing next assignment for the task
Next oResource
End If
If Not oTask Is Nothing Then
'Looping through each assignment for a task
For Each oAssignment In oTask.Assignments
'Updating the number1 field for the assignment based on value
'at task level for the number1 field
oAssignment.Text1 = oTask.Text1
Next oAssignment
End If
'Processing next task
Next oTask
End Sub
What I need to do now is figure out how to set text1 for tasks = to the current active projects filename. For example a project file will be saved as a project reference number "CR0295". I would want it to loop through all the tasks in the project and first write this value (the file name minus the extension) in text1 and then run the code to update text 1 in resources and assignments. I've searched help and can't find a way to reference the active file name. I'm sure I'm probably looking in the wrong place but any help with this code is appreciated.
Sub UpdateAssignmentNumber()
'Variables for tracking current task and assignment
Dim oTask As Task
Dim oAssignment As Assignment
Dim oResource As Resource
'Looping through all tasks in the project
For Each oTask In ActiveProject.Tasks
'Checking to see if task is blank
If Not oTask Is Nothing Then
'Looping through each assignment for a task
For Each oResource In oTask.Resources
'Updating the number1 field for the assignment based on value
'at task level for the number1 field
oResource.Text1 = oTask.Text1
'Processing next assignment for the task
Next oResource
End If
If Not oTask Is Nothing Then
'Looping through each assignment for a task
For Each oAssignment In oTask.Assignments
'Updating the number1 field for the assignment based on value
'at task level for the number1 field
oAssignment.Text1 = oTask.Text1
Next oAssignment
End If
'Processing next task
Next oTask
End Sub