LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
dl dl is offline
external usenet poster
 
Posts: 6
Default VB code to insert page breaks for Duplex/double-sided Printing

As some may know when you print a large list of data double-sided, and there
are lists within the data that should go to different parties, excel doesn't
offer the fix Word has -section breaks. So the 2nd set of data ends up on
the back of a page that has the 1st set of data on the front.

For example:
STORE# DATA DATA page orientation
1 x x -front of page 1
1 x x -back of page 1
1 x x -front of page 2
2 x x -back of page 2 <- this is the
problem
2 x x ...

To fix this I've been trying to write some VB to look for a change in column
A and where the current page number is odd. When the situation is found it
would insert a blank row and a page break on either side of the blank row,
which effectively would put a blank page on the back of a data set that ended
on the front of a page. Fixing the problem above. Unfortunately I'm pretty
new to VB and can't seem to find out where my problem is.

The error I'm having now is: Run-time error 91 Object variable or With block
variable not set

The code:
Sub FixDuplexPrinting()

'''Adjust page breaks for duplex printing'''

Dim HPageBreaks As HPageBreaks

'set focus
Range("A1").Select

'move down one cell
ActiveCell.Offset(1).Select

'loop down column A comparing cell above focus looking for change in
value (store number)
'when change is found and the current page # is odd, insert a page break
'then insert a blank row and insert another page break above the blank row
'so that store data never shares a page (on double-sided / duplex
printing)

Do Until IsEmpty(ActiveCell.Value) = True
If ActiveCell.Value < ActiveCell.Offset(-1).Value And
HPageBreaks.Count Mod 2 = 1 Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
Selection.Insert Shift:=xlDown
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
ActiveCell.Offset(1).Select

'if there isn't a change continue checking
Else
ActiveCell.Offset(1).Select

End If
Loop
End Sub

Any help is GREATLY appreciated, thank you!!!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing multiple pages (2x2) double sided with single sided print kaveh Excel Discussion (Misc queries) 11 August 8th 08 03:38 PM
Printing Double-Sided AccessNoob Excel Discussion (Misc queries) 2 November 17th 07 05:12 AM
Printing two tabs of the same worksheet to one double-sided page Jennifer Excel Discussion (Misc queries) 1 April 13th 06 07:17 PM
How do I print excel document duplex (double sided)? Kangaroo Excel Discussion (Misc queries) 1 June 23rd 05 03:26 PM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 01:58 AM


All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"