473,725 Members | 2,197 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 1378
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
2070
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
7283
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
1749
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
2769
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
6018
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
4402
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
1865
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
1484
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
3396
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
8888
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
8752
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
9401
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...
0
9257
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
9113
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
8097
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
6011
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
4519
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...
1
3221
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

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.