473,666 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.x ls";
Excel.Applicati on excelApp = new Excel.Applicati on();
excelApp.Visibl e=true;
object spreadsheetFile Name = Environment.Cur rentDirectory
+ "\\" + sheetToOpen;
Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
(Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
excelApp.Visibl e=true;
Application.Exi t();

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 4727
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******@cdfai nc.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
This code runs fine on win xp and office xp:

string sheetPassword = "Senior1993 ";
string sheetToOpen = "NewRpt1c.x ls";
Excel.Applicati on excelApp = new Excel.Applicati on();
excelApp.Visibl e=true;
object spreadsheetFile Name = Environment.Cur rentDirectory
+ "\\" + sheetToOpen;
Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
(Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
excelApp.Visibl e=true;
Application.Exi t();

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******@cdfai nc.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
This code runs fine on win xp and office xp:

string sheetPassword = "Senior1993 ";
string sheetToOpen = "NewRpt1c.x ls";
Excel.Applicati on excelApp = new Excel.Applicati on();
excelApp.Visibl e=true;
object spreadsheetFile Name = Environment.Cur rentDirectory
+ "\\" + sheetToOpen;
Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
(Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
excelApp.Visibl e=true;
Application.Exi t();

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******@cdfai nc.com> wrote:

¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993 ";
¤ string sheetToOpen = "NewRpt1c.x ls";
¤ Excel.Applicati on excelApp = new Excel.Applicati on();
¤ excelApp.Visibl e=true;
¤ object spreadsheetFile Name = Environment.Cur rentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
¤ (Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
¤ excelApp.Visibl e=true;
¤ Application.Exi t();
¤
¤ 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******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 22 '05 #4
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfai nc.com> wrote:

¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993 ";
¤ string sheetToOpen = "NewRpt1c.x ls";
¤ Excel.Applicati on excelApp = new Excel.Applicati on();
¤ excelApp.Visibl e=true;
¤ object spreadsheetFile Name = Environment.Cur rentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
¤ (Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
¤ excelApp.Visibl e=true;
¤ Application.Exi t();
¤
¤ 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******@amerit ech.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************ ***********@sws pectrum.com> wrote in message
news:d2******** *************** *********@4ax.c om...
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfai nc.com> wrote:
¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993 ";
¤ string sheetToOpen = "NewRpt1c.x ls";
¤ Excel.Applicati on excelApp = new Excel.Applicati on();
¤ excelApp.Visibl e=true;
¤ object spreadsheetFile Name = Environment.Cur rentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
¤ (Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
¤ excelApp.Visibl e=true;
¤ Application.Exi t();
¤
¤ 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******@amerit ech.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************ ***********@sws pectrum.com> wrote in message
news:d2******** *************** *********@4ax.c om...
On Sun, 16 Nov 2003 19:27:16 -0800, "Dean Bortell" <bo******@cdfai nc.com> wrote:
¤ This code runs fine on win xp and office xp:
¤
¤ string sheetPassword = "Senior1993 ";
¤ string sheetToOpen = "NewRpt1c.x ls";
¤ Excel.Applicati on excelApp = new Excel.Applicati on();
¤ excelApp.Visibl e=true;
¤ object spreadsheetFile Name = Environment.Cur rentDirectory
¤ + "\\" + sheetToOpen;
¤ Excel.Workbook excelWorkbook = excelApp.Workbo oks.Open
¤ (Convert.ToStri ng(spreadsheetF ileName), 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.W orksheets;
¤ excelApp.Visibl e=true;
¤ Application.Exi t();
¤
¤ 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******@amerit ech.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
1215
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(); excelApp.Visible=true; object spreadsheetFileName = Environment.CurrentDirectory + "\\" + sheetToOpen; Excel.Workbook excelWorkbook = excelApp.Workbooks.Open (Convert.ToString(spreadsheetFileName), 0,false,
4
3942
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" TEXT field that contains data such as 2000/01, 2001/02, etc. If I export a Query with this kind of data to Excel, it gives me the text value of this field; however, when I export a Report bound to this TEXT field, Excel gives me the values 36526,...
0
1404
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 format or 2000 format. i have a list box that works in access 97 but not 2000. here's my situation...
0
1419
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 to run the program on a Win2000/Office 2000 computer, it errs out during runtime. The error shows that the parameters are incorrect for the Open statement. The problem that I am having is that many of the Excel 2000 methods seem to take...
17
6331
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
1980
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, does anyone know any third party compononet to write excel files without having it installed? My code looks like: Public Function toExcel(ByVal fileName As String, ByVal dv As DataView)
2
15322
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 getting the error message: "Object reference not set to an instance of an object." Here is the code that generates the message: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
3
3021
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 Excel.Application Dim oWB As Excel.Workbook Dim oSheet As Excel.Worksheet oXL = GetObject(, "Excel.Application") oWB = oXL.ActiveWorkbook oSheet = oWB.ActiveSheet
3
1921
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 enough to get the idea). Here is the code: ----------------------------------------------------------------- <html>
11
1889
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 empty mdb to the 2002-2003 format. I've started to add code but discovered that non of my VB code works. Even a simple <<msgbox "test">doesn't work. I constantly get the message about miscommunication between Access and OLE souce program or Active...
0
8444
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.