473,324 Members | 2,002 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,324 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 4713
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.