473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

C# works with Excel 2002 but not Excel 2000?

This code runs fine on win xp and office xp:

string sheetPassword = "Senior1993";
string sheetToOpen = "NewRpt1c.xls";
Excel.Application excelApp = new Excel.Application();
excelApp.Visible=true;
object spreadsheetFileName = Environment.CurrentDirectory
+ "\\" + sheetToOpen;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
(Convert.ToString(spreadsheetFileName), 0,false,
Type.Missing, sheetPassword, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
excelApp.Visible=true;
Application.Exit();

However, on Windows 2000 (.net framework 1.1 installed)
with office 2000 installed it does not work! I need this
to work with office 2000. Am I doing it wrong? Please
give code examples on how to work with excel 2000
workbooks (already exist in the application folder) with
c#. Please Help!!!!
Nov 22 '05 #1
6 4715
Hi Dean,

I think you need different (primary) interop assemblies for different office
application versions.
"Currently, Microsoft provides PIAs for Office XP (and newer versions) only"
from MS website"
That makes that you have to import Excell's 2000 dll manually as normal
ActiveX library.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Dean Bortell" <bo******@cdfainc.com> wrote in message
news:03****************************@phx.gbl...
This code runs fine on win xp and office xp:

string sheetPassword = "Senior1993";
string sheetToOpen = "NewRpt1c.xls";
Excel.Application excelApp = new Excel.Application();
excelApp.Visible=true;
object spreadsheetFileName = Environment.CurrentDirectory
+ "\\" + sheetToOpen;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
(Convert.ToString(spreadsheetFileName), 0,false,
Type.Missing, sheetPassword, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
excelApp.Visible=true;
Application.Exit();

However, on Windows 2000 (.net framework 1.1 installed)
with office 2000 installed it does not work! I need this
to work with office 2000. Am I doing it wrong? Please
give code examples on how to work with excel 2000
workbooks (already exist in the application folder) with
c#. Please Help!!!!

Nov 22 '05 #2
Hi Dean,

I think you need different (primary) interop assemblies for different office
application versions.
"Currently, Microsoft provides PIAs for Office XP (and newer versions) only"
from MS website"
That makes that you have to import Excell's 2000 dll manually as normal
ActiveX library.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Dean Bortell" <bo******@cdfainc.com> wrote in message
news:03****************************@phx.gbl...
This code runs fine on win xp and office xp:

string sheetPassword = "Senior1993";
string sheetToOpen = "NewRpt1c.xls";
Excel.Application excelApp = new Excel.Application();
excelApp.Visible=true;
object spreadsheetFileName = Environment.CurrentDirectory
+ "\\" + sheetToOpen;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
(Convert.ToString(spreadsheetFileName), 0,false,
Type.Missing, sheetPassword, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
excelApp.Visible=true;
Application.Exit();

However, on Windows 2000 (.net framework 1.1 installed)
with office 2000 installed it does not work! I need this
to work with office 2000. Am I doing it wrong? Please
give code examples on how to work with excel 2000
workbooks (already exist in the application folder) with
c#. Please Help!!!!

Nov 22 '05 #3
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfainc.com> wrote:

¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993";
¤ string sheetToOpen = "NewRpt1c.xls";
¤ Excel.Application excelApp = new Excel.Application();
¤ excelApp.Visible=true;
¤ object spreadsheetFileName = Environment.CurrentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
¤ (Convert.ToString(spreadsheetFileName), 0,false,
¤ Type.Missing, sheetPassword, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing);
¤ Excel.Sheets excelSheets = excelWorkbook.Worksheets;
¤ excelApp.Visible=true;
¤ Application.Exit();
¤
¤ However, on Windows 2000 (.net framework 1.1 installed)
¤ with office 2000 installed it does not work! I need this
¤ to work with office 2000. Am I doing it wrong? Please
¤ give code examples on how to work with excel 2000
¤ workbooks (already exist in the application folder) with
¤ c#. Please Help!!!!

You need to identify what isn't working (line of code, error message?)

You may also want to consider using late binding (declare as Object).
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 22 '05 #4
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfainc.com> wrote:

¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993";
¤ string sheetToOpen = "NewRpt1c.xls";
¤ Excel.Application excelApp = new Excel.Application();
¤ excelApp.Visible=true;
¤ object spreadsheetFileName = Environment.CurrentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
¤ (Convert.ToString(spreadsheetFileName), 0,false,
¤ Type.Missing, sheetPassword, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing);
¤ Excel.Sheets excelSheets = excelWorkbook.Worksheets;
¤ excelApp.Visible=true;
¤ Application.Exit();
¤
¤ However, on Windows 2000 (.net framework 1.1 installed)
¤ with office 2000 installed it does not work! I need this
¤ to work with office 2000. Am I doing it wrong? Please
¤ give code examples on how to work with excel 2000
¤ workbooks (already exist in the application folder) with
¤ c#. Please Help!!!!

You need to identify what isn't working (line of code, error message?)

You may also want to consider using late binding (declare as Object).
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 22 '05 #5
Your project needs to reference the _oldest_ version of Excel that you
intend to support. As Miha notes, if you want to support Excel 2000 and
higher, it must reference the Excel 9 type library. (There isn't a primary
interop assembly available for older versions of office, but VS will create
an interop assembly if you reference the library.)

The app will then be compatible with Excel 2000, Excel XP and Excel 2003.
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:d2********************************@4ax.com...
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfainc.com> wrote:
¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993";
¤ string sheetToOpen = "NewRpt1c.xls";
¤ Excel.Application excelApp = new Excel.Application();
¤ excelApp.Visible=true;
¤ object spreadsheetFileName = Environment.CurrentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
¤ (Convert.ToString(spreadsheetFileName), 0,false,
¤ Type.Missing, sheetPassword, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing);
¤ Excel.Sheets excelSheets = excelWorkbook.Worksheets;
¤ excelApp.Visible=true;
¤ Application.Exit();
¤
¤ However, on Windows 2000 (.net framework 1.1 installed)
¤ with office 2000 installed it does not work! I need this
¤ to work with office 2000. Am I doing it wrong? Please
¤ give code examples on how to work with excel 2000
¤ workbooks (already exist in the application folder) with
¤ c#. Please Help!!!!

You need to identify what isn't working (line of code, error message?)

You may also want to consider using late binding (declare as Object).
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 22 '05 #6
Your project needs to reference the _oldest_ version of Excel that you
intend to support. As Miha notes, if you want to support Excel 2000 and
higher, it must reference the Excel 9 type library. (There isn't a primary
interop assembly available for older versions of office, but VS will create
an interop assembly if you reference the library.)

The app will then be compatible with Excel 2000, Excel XP and Excel 2003.
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:d2********************************@4ax.com...
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfainc.com> wrote:
¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993";
¤ string sheetToOpen = "NewRpt1c.xls";
¤ Excel.Application excelApp = new Excel.Application();
¤ excelApp.Visible=true;
¤ object spreadsheetFileName = Environment.CurrentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
¤ (Convert.ToString(spreadsheetFileName), 0,false,
¤ Type.Missing, sheetPassword, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing,
¤ Type.Missing, Type.Missing, Type.Missing, Type.Missing);
¤ Excel.Sheets excelSheets = excelWorkbook.Worksheets;
¤ excelApp.Visible=true;
¤ Application.Exit();
¤
¤ However, on Windows 2000 (.net framework 1.1 installed)
¤ with office 2000 installed it does not work! I need this
¤ to work with office 2000. Am I doing it wrong? Please
¤ give code examples on how to work with excel 2000
¤ workbooks (already exist in the application folder) with
¤ c#. Please Help!!!!

You need to identify what isn't working (line of code, error message?)

You may also want to consider using late binding (declare as Object).
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dean Bortell | last post by:
This code runs fine on win xp and office xp: string sheetPassword = "Senior1993"; string sheetToOpen = "NewRpt1c.xls"; Excel.Application excelApp = new Excel.Application();...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
0
by: Miguelito Bain | last post by:
hi everybody- i've got a conundrum... i inherited some old databases, and i'm trying to convert them. i run office xp with access 2002, and all of the databases i manage are either in 97...
0
by: Dent | last post by:
I am having a problem with a program that I wrote to format an Excel spreadsheet. I wrote the program on a WinXP/Office XP/Visual Studio .NET 2003 computer. I am using late-binding. When I try...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
3
by: Boris Condarco | last post by:
Hi gurus, I'm using excel 2000 to show data that comes from datagrid. The problem is that for any reason the asp.net application maintains the excel open, even though, i do close it. Besides,...
2
by: xhenxhe | last post by:
I don't some Excel automation. I've created a program that opens and Excel template and inputs information to it. It runs great on my machine. When I build and deploy I have a user that keep...
3
by: Ian Dunn | last post by:
I'm simply trying to access an instance of Excel that has been opened manually by the user in order to put a few values in the existing sheet. Here's the code I've tried: Dim oXL As...
3
by: patrickkellogg | last post by:
I have this code when you click the buttom is suppose to add a job history. it works with firefox, opera, but not ie. (please note - new entries don't have all the elements in them yet, but...
11
by: John | last post by:
Access 2003 After my app is finished I'd like to create an mde file. Therefore my db has to be made in the 2002-2003 format. So I've created a new mdb (default in 2000 format), I converted this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.