ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fit to page in macro (https://www.excelbanter.com/excel-programming/305929-fit-page-macro.html)

Stevenumber50

Fit to page in macro
 
Hi

I have a simple macro in Excel 97:

Sub PrintFormat()
With ActiveSheet.PageSetup
.LeftFooter = "&D&T"
.CenterFooter = "&A"
.RightFooter = "&F"
.PrintGridlines = True
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
End Sub

I run this from any worksheet page without selecting a particular block of cells. The FitToPages instructions at the end don't work. I intend to be fitting the entire worksheet contents into an A4 page, as would happen if I set these options manually in page setup.

I have a feeling I need to specify the area of the worksheet in which there is data to print. Am I right? How would I do that?

Advice gratefully received

Steve

Frank Stone

Fit to page in macro
 
here is a print setup i did on record then modified.
i think you might need to a .zoom = something.

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & LHeadTC & " " & "Total
Items"
.CenterHeader = "&16Top 50 Line Items WIP"
.RightHeader = _
"Top 50 Value Total WIP Value Percent" & Chr
(10) & _
RHead & " " & RHead1 & " " & RHead2 &
Chr(10) & _
"Top 120 Value Total WIP Value Percent" & Chr
(10) & _
RHeadD & " " & RHeadD1 & " " & RHeadD2
& Chr(10) & ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = "$A:$E"
.LeftMargin = Application.InchesToPoints(0.3)
.RightMargin = Application.InchesToPoints(0.3)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 65
End With
-----Original Message-----
Hi

I have a simple macro in Excel 97:

Sub PrintFormat()
With ActiveSheet.PageSetup
.LeftFooter = "&D&T"
.CenterFooter = "&A"
.RightFooter = "&F"
.PrintGridlines = True
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
End Sub

I run this from any worksheet page without selecting a

particular block of cells. The FitToPages instructions at
the end don't work. I intend to be fitting the entire
worksheet contents into an A4 page, as would happen if I
set these options manually in page setup.

I have a feeling I need to specify the area of the

worksheet in which there is data to print. Am I right? How
would I do that?

Advice gratefully received

Steve
.


jd

Fit to page in macro
 
..zoom = true or false. I can remembe off hand, but one of them will work.



"Frank Stone" wrote:

here is a print setup i did on record then modified.
i think you might need to a .zoom = something.

With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & LHeadTC & " " & "Total
Items"
.CenterHeader = "&16Top 50 Line Items WIP"
.RightHeader = _
"Top 50 Value Total WIP Value Percent" & Chr
(10) & _
RHead & " " & RHead1 & " " & RHead2 &
Chr(10) & _
"Top 120 Value Total WIP Value Percent" & Chr
(10) & _
RHeadD & " " & RHeadD1 & " " & RHeadD2
& Chr(10) & ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = "$A:$E"
.LeftMargin = Application.InchesToPoints(0.3)
.RightMargin = Application.InchesToPoints(0.3)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 65
End With
-----Original Message-----
Hi

I have a simple macro in Excel 97:

Sub PrintFormat()
With ActiveSheet.PageSetup
.LeftFooter = "&D&T"
.CenterFooter = "&A"
.RightFooter = "&F"
.PrintGridlines = True
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
End Sub

I run this from any worksheet page without selecting a

particular block of cells. The FitToPages instructions at
the end don't work. I intend to be fitting the entire
worksheet contents into an A4 page, as would happen if I
set these options manually in page setup.

I have a feeling I need to specify the area of the

worksheet in which there is data to print. Am I right? How
would I do that?

Advice gratefully received

Steve
.



Tom Ogilvy

Fit to page in macro
 
add

.zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

--
Regards,
Tom Ogilvy

"Stevenumber50" wrote in message
...
Hi

I have a simple macro in Excel 97:

Sub PrintFormat()
With ActiveSheet.PageSetup
.LeftFooter = "&D&T"
.CenterFooter = "&A"
.RightFooter = "&F"
.PrintGridlines = True
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
End Sub

I run this from any worksheet page without selecting a particular block of

cells. The FitToPages instructions at the end don't work. I intend to be
fitting the entire worksheet contents into an A4 page, as would happen if I
set these options manually in page setup.

I have a feeling I need to specify the area of the worksheet in which

there is data to print. Am I right? How would I do that?

Advice gratefully received

Steve




John N.

Fit to page in macro
 
"Stevenumber50" wrote in message ...
Hi

I have a simple macro in Excel 97:

Sub PrintFormat()
With ActiveSheet.PageSetup
.LeftFooter = "&D&T"
.CenterFooter = "&A"
.RightFooter = "&F"
.PrintGridlines = True
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
End Sub

I run this from any worksheet page without selecting a particular block of cells. The FitToPages instructions at the end don't work. I intend to be fitting the entire worksheet contents into an A4 page, as would happen if I set these options manually in page setup.

I have a feeling I need to specify the area of the worksheet in which there is data to print. Am I right? How would I do that?

Advice gratefully received

Steve


Steve,
I have had this problem. When I add

.zoom = false

the worksheet would print properly for me. Hope this helps.

John


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com