LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Unable Export Data to Excel on Win 2000 Server

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to export Acess Memo to Excel office 2000 sfleck Excel Discussion (Misc queries) 1 February 6th 09 07:09 AM
How to Transfer data from Excel to SQL SERVER 2000 Ahmad Jalil Qarshi Excel Discussion (Misc queries) 5 June 10th 05 08:57 PM
Export SQL Server data to EXCEL cause all column become TEXT ong Excel Programming 2 September 24th 03 11:49 AM
Read Image From SQL Server n Export to Excel Budiono Excel Programming 0 September 5th 03 10:02 AM
Export Excel to SQL Server Tom Y Excel Programming 2 August 7th 03 06:02 PM


All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"