Unwanted Sub Exit, Ws in page break preview View

N

Neal Zimm

Hi All,
Code below is part of a Sub that does route book pagination.

My problem is that the Sub EXITS on certain lines, marked
by ???? when the Ws is in page break preview view, and yet the
lines run OK when in Normal view. I do not understand.

I have not read anywhere that there is any diff when running a
macro for a Ws in preview view, yet my tests prove otherwise.
So,

Q1. When dealing with page breaks, why is there a diff between
the Normal and page break preview views ?

Q2. I have screen updating turned off, yet when the books
are large, > 50 pages, it takes a while. Is inserting page
breaks a "slow" thing?

The sub has been written to either re-page the entire route
or selected pages depending on how the calling macro inserts
or deletes rows, which equate to a page in the route book.

Thanks much,
Neal Z.

p.s. In looking at some of postings re: page breaks, there seems
to be a theme regarding the preview view.

' Get last printed row in route as needed, reset if entire route
' is being repaginated.
' MSo help, To remove all manual page breaks on a worksheet,
' set Cells.PageBreak to xlPageBreakNone. (see my comment below)

If Int(HInum / RowsPPg) >= gMinRtPgQty Then 'RowsPPg=rows per page

RtWsLasRow = RtWsLasRow_FindF(RtWs, LefCol) 'function works OK

If (LOnum = RowsPPg + 1) And HInum >= RtWsLasRow Then

RtWs.ResetAllPageBreaks 'line to left execs OK in either view.
' Sub exits on line below in page break preview view, took it out
' RtWs.Cells.xlPageBreakNone ???

If LefCol > 1 Then RtWs.Columns(LefCol).PageBreak = xlPageBreakManual

'MSO, This example sets a manual page break to the left of column J on Sheet1.
'MSO, Worksheets("Sheet1").Columns("J").PageBreak = xlPageBreakManual

' in page break preview view, sub exits after line below execs, ???
' RigCol value is 3. In Normal view, it runs OK.
RtWs.Columns(RigCol + 1).PageBreak = xlPageBreakManual

' Limit route to the last row
If HInum > (RtWsLasRow + 1) Then HInum = RtWsLasRow + 1
End If
End If


'Break the pages
For Row = LOnum To HInum Step RowsPPg

'MSo, Worksheets("Sheet1").Rows(25).PageBreak = xlPageBreakManual
'' In Normal view, this loop completes as anticipated.
'' In page break preview view, Sub EXITS after line below execs
'' when Row = HInum, ??????, (last wanted interation of loop)

If RtWs.Rows(Row).PageBreak <> xlPageBreakManual Then _
RtWs.Rows(Row).PageBreak = xlPageBreakManual

'Show status bar if > 5 pages are being re-paginated.
If ((HInum - LOnum) / RowsPPg) > 5 Then

PgNum = Int(Row / RowsPPg)

If PgNum Mod 5 = 0 Then Application.StatusBar = _
"Page Re-Number At Page " & PgNum
End If

Next Row

'There is code below here that does not exec when sub
'exits "prematurely" that I want to run, clearly an unwanted thing.

Thanks again,
Neal Z
 

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