473,698 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Excel to run a page externally from c#

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!!!!

Dean
Nov 15 '05 #1
1 1376
Dean,

If you want this to run with a version of office that came before the
version you developed for, then you have a few options:

- Get the interop assemblies for the versions of Office that you are trying
to target, and then have switch statements everywhere which will determine
which references to call based on the version of Office that is installed on
the machine (tedious, to say the least).

- Use late bound calls to call the COM components directly. This would
probably be the best solution (which coincidentally, VB is better suited
for, if you have a lot of calls, as it handles all of the late bound calls
for you automatically).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"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!!!!

Dean

Nov 15 '05 #2

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

Similar topics

2
2067
by: Marc | last post by:
Hi all, I have a problem with managing the interchange between COM/Excel and Python if the user closes the workbook externally. Everything works fine as long as the user only uses the exit keys I've provided to close the Excel apps and COM interfaces. But I really need the ability to manage the workbook if someone closes it using the 'exit' command or the right/upper 'x' from within the excel spreadsheet.
12
7277
by: guy lateur | last post by:
Hi all, I am trying to write some code (macro's, if you like) to glue together our Office applications (mainly Word, Excel and Outlook). We have a lot of different projects going on simultaneously. The idea is to develop a centralized framework (starting point, common interface) for my users to view/control their documents/correspondence, on a per project basis. As an example, I'd like to have a control (button, menu entry) in Outlook...
4
1747
by: Mark C | last post by:
I currently have an Excel spreadsheet with numerous text boxes and check boxes that I want to populate with data from an Access 97 database. I have used Excel automation in Access before but only to update cells not controls like text boxes. Can someone steer me onto the correct path? I am not using a VBA form in Excel it is just merely various text boxes and checkboxes placed on a worksheet. Any help would be much appreciated.
3
2768
by: Oscar F | last post by:
Hello, To create a excel report from ASP.NET I do the folowing steps: -Create a HTML document. -Use Response.ContentType = "application/vnd.ms-excel" Everything works fine and the excel report is shown inside the IE. The problem is when I try to save the page, this message appears:
7
6014
by: Stu | last post by:
Hi, I have a web service which returns a record set and works well integrated with an asp dot net page. However if I decided to develop a unix app will i be able to read the dataset as it is or do i need to write the xml as text from the web service and supply a DTD. Also any other pitfalls TIA
4
4400
by: Eric W | last post by:
I am converting an EXCEL VBA application to Visual Basic (2003). I am not having much luck finding how to convert statements containing references to things like ThisWorkbook.Sheets("sheetname"). I am not using Visual Studio Tools (which may be my problem, tho I would think that I don't really need the templates --- or do I??) Eric
1
1864
by: balaji | last post by:
Hi all, Is there a way to use .Net remoting via Excel macros?. I want to do is if a particular cells in the excel file changes, my .Net applicaiton need to be notified about this. Is there any other way of interprocess communicatin between excel and my app? All i need is my application loads a excel file to read data but if the excel file is change externally by any other process or user, i need to be notified so that my application...
6
1482
by: emorgoch | last post by:
Hi there. I'm currently working on a project involving rebuilding our local intranet site. The site was originally developed using frames, defining a header, sidebar, and content area, which I've been working to replace using ASP.NET master pages. Right now I'm trying to find a solution for some of our older and externally linked content. A good proportion of this content get loaded into the content frame, leaving the header and...
3
3394
by: Shawn T | last post by:
I have an application with a page that has a web user control When I call that page that has this user control, locally (http:// localhost/ApplicationX/default.aspx) and also externally ie (http:// <webserver>/ApplicationX/default.aspx), the display is all different. For example, a text box shows with border on one and textbox shows as label in the other. I am suspecting that it might be CSS issue. I checked the CSS file and everything...
0
8674
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
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
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...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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();...
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.