Solved

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

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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

707 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