Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Print two different areas on a worksheet

I'm using excel 2003 and want to print two different areas on a sheet. Here
is the code I'm using, but when I run it, it locks up sending an error report
to MS.

ActiveSheet.PageSetup.PrintArea = "$a$1:$l$64"


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.PageSetup.PrintArea = ""


ActiveSheet.PageSetup.PrintArea = "$a$65:$l$127"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print two different areas on a worksheet


Works fine for me. You don't need the third line.


--
shg
------------------------------------------------------------------------
shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24092

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Print two different areas on a worksheet

It works for me if I only do the first print. When I put in the second
print, it locks up. MS sends me an error report and shuts down excel. I'll
try leaving the line out and see if that works.

"bigjim" wrote:

I'm using excel 2003 and want to print two different areas on a sheet. Here
is the code I'm using, but when I run it, it locks up sending an error report
to MS.

ActiveSheet.PageSetup.PrintArea = "$a$1:$l$64"


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.PageSetup.PrintArea = ""


ActiveSheet.PageSetup.PrintArea = "$a$65:$l$127"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Print two different areas on a worksheet

I think I'd try something like this

Dim myRange As Range
Dim aWS As Worksheet

Set aWS = ActiveSheet
Set myRange = aWS.Range("$a$1:$l$64")
Debug.Print myRange.Address
myRange.PrintOut copies:=1, Collate:=True

Set myRange = aWS.Range("$a$651:$l$127")
myRange.PrintOut copies:=1, Collate:=True

I can't test it because I don't have a printer set up here.
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"bigjim" wrote:

I'm using excel 2003 and want to print two different areas on a sheet. Here
is the code I'm using, but when I run it, it locks up sending an error report
to MS.

ActiveSheet.PageSetup.PrintArea = "$a$1:$l$64"


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.PageSetup.PrintArea = ""


ActiveSheet.PageSetup.PrintArea = "$a$65:$l$127"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default Print two different areas on a worksheet

i've just adapted a report i've used in the past. try it, just change the
references to the worksheet, margins, headers and titlerows


Option Explicit
Sub Print_Report()
Dim ws As Worksheet
Dim rng As Range
Dim lastrow As Long
Dim prnArray As Variant
Dim i As Long
Application.ScreenUpdating = False
Set ws = Worksheets("Report")
ws.Unprotect
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
prnArray = Array("a1:L64", "a65:L127")

For i = LBound(prnArray) To UBound(prnArray)
Set rng = ws.Range(prnArray(i))
With ws.PageSetup
.Orientation = xlLandscape
.PrintTitleRows = "$" & 3 & ":" & "$" & 4
.CenterHorizontally = True
.CenterVertically = False
.FooterMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0.35)
.LeftMargin = Application.InchesToPoints(0.35)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.4)
.FooterMargin = Application.InchesToPoints(0#)
.PrintArea = rng.Address
.HeaderMargin = Application.InchesToPoints(0.25)
.RightHeader = "&B&12 " & ws.Range("B2").Value
.CenterHeader = "&B&16" & "Production Tracking"
.RightFooter = "Page " & "&P" & " of " & "&N" & " " & _
Format(Now, "h:mmAM/PM MM/dd/yy")
.CenterFooter = ""
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 10
.PrintGridlines = True
End With
ws.PrintPreview
Next
'Clear Print area
With ws.PageSetup
.PrintArea = ""
End With
Application.ScreenUpdating = True
ws.Protect
End Sub


--

Gary
Excel 2003


"bigjim" wrote in message
...
I'm using excel 2003 and want to print two different areas on a sheet.
Here
is the code I'm using, but when I run it, it locks up sending an error
report
to MS.

ActiveSheet.PageSetup.PrintArea = "$a$1:$l$64"


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.PageSetup.PrintArea = ""


ActiveSheet.PageSetup.PrintArea = "$a$65:$l$127"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Print two different areas on a worksheet

Hi,

And this are just modifications to your code, but it already worked for me
without changes.

With ActiveSheet.PageSetup
.PrintArea = "$a$1:$l$64"
ActiveWindow.SelectedSheets.PrintOut
.PrintArea = "$a$65:$l$127"
ActiveWindow.SelectedSheets.PrintOut
End With

One copy is the default, and with one copy collate is irrelevant
--
Thanks,
Shane Devenshire


"bigjim" wrote:

I'm using excel 2003 and want to print two different areas on a sheet. Here
is the code I'm using, but when I run it, it locks up sending an error report
to MS.

ActiveSheet.PageSetup.PrintArea = "$a$1:$l$64"


ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.PageSetup.PrintArea = ""


ActiveSheet.PageSetup.PrintArea = "$a$65:$l$127"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Reply
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
variable print areas same worksheet joemeshuggah Excel Programming 0 October 28th 08 02:53 PM
Can I adjust print scaling for multiple print areas on the same sh N. Sammons Excel Discussion (Misc queries) 0 June 18th 08 10:24 PM
Need to print a workbook but worksheets have diff print areas Angela Steele Excel Discussion (Misc queries) 1 January 17th 08 07:39 PM
printing multiple print areas with a print dialog box LHaro Excel Programming 0 August 17th 05 09:56 PM
Multiple print areas, one worksheet -need to print to PDF! mohagany19 Excel Programming 0 October 6th 04 11:54 PM


All times are GMT +1. The time now is 01:26 AM.

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

About Us

"It's about Microsoft Excel"