|
|
|
This code will show you - How to make column width to auto fit - How to set column width - How to set papersize - How to set page orientation |
Click here to copy the following block | Sub SetXLSPrintLayout(XLSFilePath As String) On Error GoTo errHandler Dim ps As Excel.PageSetup Set objExcel = CreateObject("Excel.Application") objExcel.Visible = False objExcel.Workbooks.Open XLSFilePath objExcel.DisplayAlerts = False
objExcel.ActiveSheet.PageSetup.Orientation = xlLandscape objExcel.ActiveSheet.PageSetup.PaperSize = xlPaperLegal objExcel.ActiveSheet.PageSetup.LeftMargin = objExcel.Application.InchesToPoints(0.5) objExcel.ActiveSheet.PageSetup.RightMargin = objExcel.Application.InchesToPoints(0.5) objExcel.ActiveSheet.PageSetup.TopMargin = objExcel.Application.InchesToPoints(0.5) objExcel.ActiveSheet.PageSetup.BottomMargin = objExcel.Application.InchesToPoints(0.5) objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.ActiveWorkbook.Save objExcel.Workbooks.Close objExcel.DisplayAlerts = True objExcel.Quit Exit Sub errHandler: Err.Raise Err.Number, Err.Source, Err.Description End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|