Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Unable Export Data to Excel on Win 2000 Server

Just a guess - does the server have a printer installed? Page Setup will
fail if not I believe.

--
Jim Rech
Excel MVP
"Vkarumbaiah" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Unable Export Data to Excel on Win 2000 Server

hi Jim
The server is not directly connected to a printer however it can print to a
network printer that is accessed via print server on the network. Do you
think the printer 's drivers should be installed on the server where I am
trying to run the code?

Also the Win 2000 server I am using to run this code has terminal services
enabled, and is configured to run applications, do you know if this would
cause any problems?

Thank you for your reply
Vikram Karumbaiah


"Jim Rech" wrote:

Just a guess - does the server have a printer installed? Page Setup will
fail if not I believe.

--
Jim Rech
Excel MVP
"Vkarumbaiah" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Unable Export Data to Excel on Win 2000 Server

Do you think the printer 's drivers should be installed on the server
where I am trying to run the code?


If you can manually use File, Page Setup then you're okay. If you cannot do
it manually then a macro could not do it either. So it you can go into Page
Setup I'd go one step farther and try setting the paper size manually to
Legal. If you cannot do that (say the driver does not support that paper
size) it would explain the macro error. If it works okay I really don't
know why your code is failing.

--
Jim Rech
Excel MVP
"vkarumbaiah" wrote in message
...
| hi Jim
| The server is not directly connected to a printer however it can print to
a
| network printer that is accessed via print server on the network. Do you
| think the printer 's drivers should be installed on the server where I am
| trying to run the code?
|
| Also the Win 2000 server I am using to run this code has terminal services
| enabled, and is configured to run applications, do you know if this would
| cause any problems?
|
| Thank you for your reply
| Vikram Karumbaiah
|
|
| "Jim Rech" wrote:
|
| Just a guess - does the server have a printer installed? Page Setup
will
| fail if not I believe.
|
| --
| Jim Rech
| Excel MVP
| "Vkarumbaiah" wrote in message
| ...
| 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
|
|
|


Reply
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 03:52 PM.

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"