?
Solved

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

Posted on 2014-09-18
2
Medium Priority
?
3,148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 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

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

770 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