Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have a VB.Net 2003 Assembly in which I am 1 . executing a stored in a database and filling a dataset 2 . Populating the data retrieved in to an Excel Spread sheet 3 . Setting the PageSetup properties of the worksheet 4. saving the Excel File to disk My code works fine on a windows XP machine with SP2 but fails at the following line on Win 2000 With SP4 objXLWorksheet.PageSetup.PaperSize = CType(Microsoft.Office.Interop.Excel.XlPaperSize.x lPaperLegal, Microsoft.Office.Interop.Excel.XlPaperSize) 'Set Paper size to Legal The exception Message is Unable to set the PaperSize property of the PageSetup My code is as below Imports System.IO Imports Office = Microsoft.Office.Core Imports Microsoft.Office.Interop.Excel Imports System.Data.SqlClient Imports System.Configuration Imports Microsoft.Office.Interop.Excel.Constants Imports System.Xml Dim objExcelApp As New Microsoft.Office.Interop.Excel.Application Dim objWB As Microsoft.Office.Interop.Excel.Workbook Dim objSH As Microsoft.Office.Interop.Excel.Worksheet 'Open the file that was created Using the Excel Object model. objExcelApp.Workbooks.Open("C:\temp\NewspaperRepor t.xls") 'Assign the Activeworksheet to a Worksheet object objSH = objExcelApp.ActiveWorkbook.ActiveSheet 'Set properties for the Active Worksheet With objSH .Columns.ColumnWidth = 2.39 'Q1 Select .Range("E1", "BD1").Interior.ColorIndex = 3 .Range("A1", "BD1").Rows(1).rowheight = 29.25 .Rows(1).Font.Name = "Arial" .Rows(1).Font.ColorIndex = 2 .Rows(1).Font.Bold = True .Rows(1).Font.Size = 12 .Rows(1).VerticalAlignment = CType(Microsoft.Office.Interop.Excel.XlVAlign.xlVA lignCenter, Microsoft.Office.Interop.Excel.XlVAlign) .Name = "Local Newspaper" .Columns.WrapText = False .PageSetup.PaperSize = CType(Microsoft.Office.Interop.Excel.XlPaperSize.x lPaperLegal, Microsoft.Office.Interop.Excel.XlPaperSize) .PageSetup.Orientation = CType(Microsoft.Office.Interop.Excel.XlPageOrienta tion.xlLandscape, Microsoft.Office.Interop.Excel.XlPageOrientation) .PageSetup.Zoom = 55 'Set Printing Margins .PageSetup.HeaderMargin = objExcelApp.InchesToPoints(0.25) .PageSetup.TopMargin = objExcelApp.InchesToPoints(0.5) .PageSetup.LeftMargin = objExcelApp.InchesToPoints(0.25) .PageSetup.RightMargin = objExcelApp.InchesToPoints(0.25) .PageSetup.BottomMargin = objExcelApp.InchesToPoints(0.5) .PageSetup.FooterMargin = objExcelApp.InchesToPoints(0.25) .PageSetup.CenterHeader = "Local Newspaper" .PageSetup.RightFooter = "Report generated on " & "&D page &P of &N" .PageSetup.PrintTitleRows() = .Rows(1).Address .PageSetup.PrintGridlines = True .Range("E5", "E5").Select() End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to export Acess Memo to Excel office 2000 | Excel Discussion (Misc queries) | |||
How to Transfer data from Excel to SQL SERVER 2000 | Excel Discussion (Misc queries) | |||
Export SQL Server data to EXCEL cause all column become TEXT | Excel Programming | |||
Read Image From SQL Server n Export to Excel | Excel Programming | |||
Export Excel to SQL Server | Excel Programming |