PDA

View Full Version : Solved: Moving Page Breaks



ProteanBeing
03-14-2008, 06:16 AM
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

Trevor
03-14-2008, 01:04 PM
try using the ascii value for your page break or ascii value for new page instead of page break

http://www.asciitable.com/

ProteanBeing
03-14-2008, 01:12 PM
Two questions:
1. Which ACSII code do I use
2. Where/how would I use it

Trevor
03-14-2008, 05:45 PM
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

ProteanBeing
03-19-2008, 11:07 AM
how does that create a page break?

lucas
03-19-2008, 11:22 AM
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.

ProteanBeing
03-19-2008, 11:42 AM
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
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).

Trevor
03-19-2008, 12:14 PM
try changing,

.Rows(ReportRow).PageBreak

to

.Rows(ReportRow) & Chr$(10) = xlPageBreakManual

that should enter a blank line/newpage at that point on your report

ProteanBeing
03-25-2008, 07:20 AM
I get a "Object doesn't support this property or method" Error when running this way.

ProteanBeing
03-25-2008, 07:38 AM
I fixed it. Use .cells(ReportRow, 1) instead of .rows(ReportRow)