Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Print sub returns

PRINT1 WORKS FINE; PRINT2 RETURNS A RUN-TIME 1004 ERROR. EACH SUB REFERS TO A
DIFFERENT WORKSHEET IN A WORKBOOK.

Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006

Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Sub Print2()


Worksheets("Assumptions").Activate
Range("A1:D33").Select
ActiveSheet.PageSetup.PrintArea = "A1:D33"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub


--
Peace
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Print sub returns

I tested sub 2, as written, and it worked just fine. However, you don't need
selections. This will work from anywhere in the workbook. This type macro is
very slow so I strongly suggest you eliminate any unnecessary lines in the
code below or use another macro to JUST set up the constants and do it ONCE
instead of each time.

Sub Print2()
With Worksheets("sheet8").PageSetup
.PrintArea = "A1:D33"

.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
Sheets("sheet8").PrintOut
End Sub

--
Don Guillett
SalesAid Software

"Montana" wrote in message
...
PRINT1 WORKS FINE; PRINT2 RETURNS A RUN-TIME 1004 ERROR. EACH SUB REFERS
TO A
DIFFERENT WORKSHEET IN A WORKBOOK.

Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006

Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Sub Print2()


Worksheets("Assumptions").Activate
Range("A1:D33").Select
ActiveSheet.PageSetup.PrintArea = "A1:D33"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub


--
Peace



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Print sub returns

Solution worked great!

Thanks
--
Peace


"Montana" wrote:

PRINT1 WORKS FINE; PRINT2 RETURNS A RUN-TIME 1004 ERROR. EACH SUB REFERS TO A
DIFFERENT WORKSHEET IN A WORKBOOK.

Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006

Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Sub Print2()


Worksheets("Assumptions").Activate
Range("A1:D33").Select
ActiveSheet.PageSetup.PrintArea = "A1:D33"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub


--
Peace

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Print sub returns

Worked great!

Thanks
--
Peace


"Don Guillett" wrote:

I tested sub 2, as written, and it worked just fine. However, you don't need
selections. This will work from anywhere in the workbook. This type macro is
very slow so I strongly suggest you eliminate any unnecessary lines in the
code below or use another macro to JUST set up the constants and do it ONCE
instead of each time.

Sub Print2()
With Worksheets("sheet8").PageSetup
.PrintArea = "A1:D33"

.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
Sheets("sheet8").PrintOut
End Sub

--
Don Guillett
SalesAid Software

"Montana" wrote in message
...
PRINT1 WORKS FINE; PRINT2 RETURNS A RUN-TIME 1004 ERROR. EACH SUB REFERS
TO A
DIFFERENT WORKSHEET IN A WORKBOOK.

Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006

Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Sub Print2()


Worksheets("Assumptions").Activate
Range("A1:D33").Select
ActiveSheet.PageSetup.PrintArea = "A1:D33"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub


--
Peace




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Print sub returns

glad to help but I don't know why your original didn't work.

--
Don Guillett
SalesAid Software

"Montana" wrote in message
...
Worked great!

Thanks
--
Peace


"Don Guillett" wrote:

I tested sub 2, as written, and it worked just fine. However, you don't
need
selections. This will work from anywhere in the workbook. This type macro
is
very slow so I strongly suggest you eliminate any unnecessary lines in
the
code below or use another macro to JUST set up the constants and do it
ONCE
instead of each time.

Sub Print2()
With Worksheets("sheet8").PageSetup
.PrintArea = "A1:D33"

.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
Sheets("sheet8").PrintOut
End Sub

--
Don Guillett
SalesAid Software

"Montana" wrote in message
...
PRINT1 WORKS FINE; PRINT2 RETURNS A RUN-TIME 1004 ERROR. EACH SUB
REFERS
TO A
DIFFERENT WORKSHEET IN A WORKBOOK.

Sub Print1()
'
'
' Print Macro
' Macro written 6/28/2006 by djones
' Copied here 10/12/2006

Worksheets("Summary").Activate
Range("A1:AA22").Select
ActiveSheet.PageSetup.PrintArea = "A1:AA22"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("A:B").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Sub Print2()


Worksheets("Assumptions").Activate
Range("A1:D33").Select
ActiveSheet.PageSetup.PrintArea = "A1:D33"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "TCM EOM 07 Summary"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "Page &P"
.FirstPageNumber = "1"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintTitleColumns = ActiveSheet.Columns("a:b").Address
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FitToPagesTall = 1
.FitToPagesWide = 1
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100


.PrintErrors = xlPrintErrorsDisplayed
End With

' ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintPreview
End Sub


--
Peace






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
Index with mulitple value returns and muliple column returns solar+CSE Excel Worksheet Functions 4 June 12th 09 04:43 PM
Date returns always returns: 00 January 1900 ArcticWolf Excel Worksheet Functions 2 September 11th 08 12:31 PM
cell with value returns that value, empty cell returns zero tamarak Excel Worksheet Functions 2 November 15th 06 11:51 AM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Need Help w/ Print Macro to Print All Visible Sheets (including Charts) in a Workbook will Excel Programming 3 September 23rd 04 08:05 PM


All times are GMT +1. The time now is 04:15 PM.

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"