Consulting

Results 1 to 10 of 10

Thread: Solved: Moving Page Breaks

  1. #1
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location

    Solved: Moving Page Breaks

    I have created a program to generate a report of unknown pages. It filters out items from the list and displays them (like a continuous report from Access). It keeps giving me an error "Unable to set the Pagebreak property of the range class". However if I debug then continue, it will run correctly (it does this for each pagebreak). Please help
    Last edited by ProteanBeing; 03-14-2008 at 07:20 AM.
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  2. #2
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location
    try using the ascii value for your page break or ascii value for new page instead of page break

    http://www.asciitable.com/

  3. #3
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    Two questions:
    1. Which ACSII code do I use
    2. Where/how would I use it
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  4. #4
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location
    where the code is for page brage replace that with Chr$(10) witch givds you a blank line, or a new line, depending how you want to look at it
    you may need to use & Chr$(10) depending how your code is if you need to concatinate you would use & Chr$(10)
    concatinate = string 2 or more commands or text strings together

  5. #5
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    how does that create a page break?
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Protean, I for one have no idea how this might look.....

    I have no idea if each sheet has multiple pages and I have to assume that it does....does this go across multiple sheets and are you considering them to be pages?

    What code are you using and how does the data look?

    post an example workbook....take every thing out except the problem so we can see what is happening and comment it so we can understand.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    [vba]For Each EachRow In _
    MLog.Range(MLog.Cells(2, 1), MLog.Cells(LogLength, 1)) _
    .SpecialCells(xlCellTypeVisible)
    ' do some work then add to report below
    ReportCount = ReportCount + 1
    On Error Resume Next
    ReportRow = ReportRow + 2
    If ReportCount Mod 12 = 0 Then
    With SortedReport
    .PageSetup.PrintArea = "$B$2:$K$" + Format(ReportRow + 1)
    .Rows(ReportRow).PageBreak = xlPageBreakManual
    End With
    End If
    On Error GoTo 0

    Next EachRow[/vba]
    The report is filtered. All items that are still visible in the list are placed on the report. Every 12th item should trigger the page break. The On Error is the only way I could make the program not give me errors, however sometimes I get what appears like an endless loop (I have to hard break).
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  8. #8
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location
    try changing,
    [VBA]
    .Rows(ReportRow).PageBreak
    [/VBA]
    to
    [VBA]
    .Rows(ReportRow) & Chr$(10) = xlPageBreakManual
    [/VBA]
    that should enter a blank line/newpage at that point on your report

  9. #9
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    I get a "Object doesn't support this property or method" Error when running this way.
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

  10. #10
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location
    I fixed it. Use .cells(ReportRow, 1) instead of .rows(ReportRow)
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •