Solved

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

Posted on 2014-09-18
2
2,583 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now