Solved

Excel 2010 VB.Net Print Settings Fit all columns on one page

Posted on 2014-09-18
2
2,729 Views
Last Modified: 2014-09-18
I am creating an Excel worksheet for users and need to set the printing properties in code.
The problem I have is trying to find the correct property settings to "fit all columns across one page."
' Highlight the full range used on sheet and set print area and printing properties
							' objRange1 = .Range(.Cells(#1st Row, #1st Col), .Cells(#Rows, #Last Col))
							objRange1 = .Range(.Cells(1, 1), .Cells(intSpreadsheetRow, 8))
							objRange1.Select()

							With .PageSetup

								.PrintArea = objRange1.Address
								.LeftHeader = ""
								.CenterHeader = "Un-Allocated Sales Order Lines with Free Stock"
								.RightHeader = ""
								.LeftFooter = ""
								.CenterFooter = "Page &P of &N"
								.RightFooter = ""
								.PrintHeadings = False
								.PrintGridlines = False
								.PrintComments = Excel.XlPrintLocation.xlPrintNoComments
								.PrintQuality = 600
								.CenterHorizontally = False
								.CenterVertically = False
								.Orientation = Excel.XlPageOrientation.xlLandscape
								.Draft = False
								.PaperSize = Excel.XlPaperSize.xlPaperA4
								.FirstPageNumber = Excel.Constants.xlAutomatic
								.Order = Excel.XlOrder.xlDownThenOver
								.BlackAndWhite = False
								.Zoom = False
								.FitToPagesWide = 1
								'.FitToPagesTall = 0
								.PrintErrors = Excel.XlPrintErrors.xlPrintErrorsDisplayed
								.OddAndEvenPagesHeaderFooter = False
								.DifferentFirstPageHeaderFooter = False
								.ScaleWithDocHeaderFooter = True
								.AlignMarginsHeaderFooter = True
								
							End With

Open in new window

0
Comment
Question by:TeDeSm
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40329982
With .PageSetup
                                                .Zoom = False
                                                .FitToPagesWide = 1
                                                .FitToPagesTall = False                                          
                                          End With
0
 

Author Closing Comment

by:TeDeSm
ID: 40330140
Thanks Phillip, nearly had it but had set .Fit ToPagesTall = 0 which did not appear to work.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question