none
Print with page break every new resource entry RRS feed

  • Question

  • hi,

    I have a project plan and I want to print it as PDF and hand detailed plans for each resource in the plan.

    i grouped the tasks per resource.

    is there an option to have an automated page break so that for each resource the tasks will start in a new page?

    * we use Project 2010

    Thanks,

    Yuval

    Tuesday, June 14, 2016 10:27 AM

Answers

  • Yuval,

    As far as I know there are only two ways to do what you want, either manually or with some VBA. The latter would be "automated".

    Hope this helps.

    John

    • Marked as answer by Yuval.p Tuesday, June 14, 2016 3:20 PM
    Tuesday, June 14, 2016 3:18 PM
  • Yuval,

    Okay, a couple days later, but this code should do what you want.

    John

    Option Explicit
    Public TotRows As Integer, i As Integer
    Sub setPgBrks()
    'This macro was developed to insert page breaks for each resource's assignments
    'when grouped by resource name in the Gantt Chart view. It works best when
    'there is only one assigned resource per task.
    'Witten by John - Project
    '   version 1.0 6/18/16
    Dim t As Task
    Dim r As Resource
    Dim NumAss As Integer
    Dim CurView As String
    'Since there is no direct method for determineing the total number of rows in
    '   a grouped view, an indirect method must be used.
    TotRows = 0
    For Each r In ActiveProject.Resources
        NumAss = r.Assignments.count
        'total rows will be number of assignments plus 1 for group summary row
        If NumAss > 0 Then TotRows = TotRows + NumAss + 1
    Next r
    'First, set up the view, create and apply filter to isolate only task with resources assigned
    '   then create group for resource names and apply group
    CurView = ActiveProject.CurrentView
    OutlineShowAllTasks
    FilterApply Name:="all tasks"
    GroupClear  'remove current group if present
    FilterEdit Name:="Pg brk", taskfilter:=True, create:=True, overwriteexisting:=True, _
        FieldName:="resource names", test:="does not contain", Value:="", _
        ShowInMenu:=False, showsummarytasks:=False
    FilterApply Name:="Pg brk"
    On Error Resume Next    'need if group already exists
    ActiveProject.TaskGroups.Add Name:="ResNamGrp", FieldName:="resource names"
    On Error GoTo 0
    GroupApply Name:="ResNamGrp"
    'Second, set page breaks for each group
    SetPgBrk
    'Third, save as PDF
    DocumentExport FileName:=ActiveProject.Name & "PDF", FileType:=pjPDF
    'Finally, remove page breaks that were set, clear the group and restore the original view
    '   Note, Remove All Page Breaks Method does not work for group summary lines but
    '   repeating set process will effectively remove them
    SetPgBrk
    GroupClear
    ViewApply Name:=CurView
    End Sub
    Private Sub SetPgBrk()
    'Cycle through all rows in current filtered/grouped view and look for
    '   group summary rows. Set page break for each.
    '   Note, since group summary rows are not tasks, need to detect and handle error
    For i = 1 To TotRows
        SelectRow Row:=i, rowrelative:=False, Height:=0
        On Error Resume Next
        If ActiveSelection.Tasks(1).ID > 0 Then i = i 'do nothing, not a group summary
        If Err > 0 And i <> 1 Then PageBreakSet 'group summary detected, set page break
        On Error GoTo 0
    Next
    End Sub

    • Marked as answer by Yuval.p Sunday, July 3, 2016 1:52 PM
    Saturday, June 18, 2016 5:28 PM

All replies

  • Yuval,

    As far as I know there are only two ways to do what you want, either manually or with some VBA. The latter would be "automated".

    Hope this helps.

    John

    • Marked as answer by Yuval.p Tuesday, June 14, 2016 3:20 PM
    Tuesday, June 14, 2016 3:18 PM
  • thanks. i did it manually, although it is time consuming.

    Tuesday, June 14, 2016 3:20 PM
  • Yuval,

    You're welcome and thanks for the feedback. If you need to do this on a regular basis, it could be automated with some VBA. If you'd like some code for that, let me know.

    John

    Tuesday, June 14, 2016 3:32 PM
  • That would certainly help.

    Appreciate your assistance!

    Tuesday, June 14, 2016 3:48 PM
  • Yuval,

    You say you grouped the tasks by resource. Is that the Gantt Chart view? If so, may I assume there is only one resource per task? How about using the Resource Usage view, that way no grouping is needed, just print out each resource with their assignments per page. Will that work for you?

    John

    Tuesday, June 14, 2016 5:34 PM
  • John,

    I want to include the Gantt chart also in the printout so our resources have a clear visual way of understanding their personal plans.

    Yuval

    Wednesday, June 15, 2016 5:07 AM
  • Yuval,

    Okay but just to confirm, are you grouping on the Resource Names field? Is there only one resource assigned to each task or do you have multiple resources assigned to some tasks?

    John

    Wednesday, June 15, 2016 12:46 PM
  • John,

    yes, we group on the resource field. we assign only one resource to a given task.

    Thanks,

    Yuval

    Wednesday, June 15, 2016 1:12 PM
  • Yuval,

    Okay, I'll work on the macro to insert page breaks later today.

    John

    Wednesday, June 15, 2016 2:04 PM
  • Yuval,

    Okay, a couple days later, but this code should do what you want.

    John

    Option Explicit
    Public TotRows As Integer, i As Integer
    Sub setPgBrks()
    'This macro was developed to insert page breaks for each resource's assignments
    'when grouped by resource name in the Gantt Chart view. It works best when
    'there is only one assigned resource per task.
    'Witten by John - Project
    '   version 1.0 6/18/16
    Dim t As Task
    Dim r As Resource
    Dim NumAss As Integer
    Dim CurView As String
    'Since there is no direct method for determineing the total number of rows in
    '   a grouped view, an indirect method must be used.
    TotRows = 0
    For Each r In ActiveProject.Resources
        NumAss = r.Assignments.count
        'total rows will be number of assignments plus 1 for group summary row
        If NumAss > 0 Then TotRows = TotRows + NumAss + 1
    Next r
    'First, set up the view, create and apply filter to isolate only task with resources assigned
    '   then create group for resource names and apply group
    CurView = ActiveProject.CurrentView
    OutlineShowAllTasks
    FilterApply Name:="all tasks"
    GroupClear  'remove current group if present
    FilterEdit Name:="Pg brk", taskfilter:=True, create:=True, overwriteexisting:=True, _
        FieldName:="resource names", test:="does not contain", Value:="", _
        ShowInMenu:=False, showsummarytasks:=False
    FilterApply Name:="Pg brk"
    On Error Resume Next    'need if group already exists
    ActiveProject.TaskGroups.Add Name:="ResNamGrp", FieldName:="resource names"
    On Error GoTo 0
    GroupApply Name:="ResNamGrp"
    'Second, set page breaks for each group
    SetPgBrk
    'Third, save as PDF
    DocumentExport FileName:=ActiveProject.Name & "PDF", FileType:=pjPDF
    'Finally, remove page breaks that were set, clear the group and restore the original view
    '   Note, Remove All Page Breaks Method does not work for group summary lines but
    '   repeating set process will effectively remove them
    SetPgBrk
    GroupClear
    ViewApply Name:=CurView
    End Sub
    Private Sub SetPgBrk()
    'Cycle through all rows in current filtered/grouped view and look for
    '   group summary rows. Set page break for each.
    '   Note, since group summary rows are not tasks, need to detect and handle error
    For i = 1 To TotRows
        SelectRow Row:=i, rowrelative:=False, Height:=0
        On Error Resume Next
        If ActiveSelection.Tasks(1).ID > 0 Then i = i 'do nothing, not a group summary
        If Err > 0 And i <> 1 Then PageBreakSet 'group summary detected, set page break
        On Error GoTo 0
    Next
    End Sub

    • Marked as answer by Yuval.p Sunday, July 3, 2016 1:52 PM
    Saturday, June 18, 2016 5:28 PM
  • John,

    Thanks a lot! I'll check if it works for me.

    Yuval

    Sunday, July 3, 2016 6:13 AM
  • John,

    I checked the macro and it works perfectly!

    thanks again,

    Yuval

    Sunday, July 3, 2016 1:53 PM
  • Yuval,

    You're welcome and thanks for the feedback.

    John

    Sunday, July 3, 2016 2:28 PM