473,327 Members | 2,090 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,327 software developers and data experts.

Getting FileNotFoundException when adding Excel workbook

I'm getting a Sysmte.IO.FileNotFoundException when executing the code
below.
It is straight from the example. This works on one machine, but not
the other. Other benign calls invoke the same misbehavior which as
ActiveWorkbook or Active Worksheet.

Please help!

peace,
- mike

Excel.Application app = new Excel.Application();
if (app == null) {
Console.WriteLine("ERROR: EXCEL couldn't be started!");
return false;
}

Console.WriteLine ("Making application visible");
app.Visible = true;

Console.WriteLine ("Getting the workbooks collection");
Workbooks workbooks = app.Workbooks;

Console.WriteLine ("Adding a new workbook");

try {
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);

} catch (System.IO.FileNotFoundException) {
Console.WriteLine("Always gets here.");
}
....
Nov 15 '05 #1
2 3840
Michael,

Which line of the code do you get the error on? What is the difference
between machines that it works on and ones it doesn't? Is the version of
Excel the same on all the machines?

John Wiese
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Michael Sanford" <ms**********@comcast.net> wrote in message
news:d3************************@posting.google.com ...
I'm getting a Sysmte.IO.FileNotFoundException when executing the code
below.
It is straight from the example. This works on one machine, but not
the other. Other benign calls invoke the same misbehavior which as
ActiveWorkbook or Active Worksheet.

Please help!

peace,
- mike

Excel.Application app = new Excel.Application();
if (app == null) {
Console.WriteLine("ERROR: EXCEL couldn't be started!");
return false;
}

Console.WriteLine ("Making application visible");
app.Visible = true;

Console.WriteLine ("Getting the workbooks collection");
Workbooks workbooks = app.Workbooks;

Console.WriteLine ("Adding a new workbook");

try {
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);

} catch (System.IO.FileNotFoundException) {
Console.WriteLine("Always gets here.");
}
...

Nov 15 '05 #2
I found the problem. Excel had trouble loading some libraries at
startup (nothing to do with my C# application). I reinstalled Office
and everything "now works".

peace,
- mike
"John Wiese [MS]" <jw****@online.microsoft.com> wrote in message news:<eE**************@TK2MSFTNGP10.phx.gbl>...
Michael,

Which line of the code do you get the error on? What is the difference
between machines that it works on and ones it doesn't? Is the version of
Excel the same on all the machines?

John Wiese
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Michael Sanford" <ms**********@comcast.net> wrote in message
news:d3************************@posting.google.com ...
I'm getting a Sysmte.IO.FileNotFoundException when executing the code
below.
It is straight from the example. This works on one machine, but not
the other. Other benign calls invoke the same misbehavior which as
ActiveWorkbook or Active Worksheet.

Please help!

peace,
- mike

Excel.Application app = new Excel.Application();
if (app == null) {
Console.WriteLine("ERROR: EXCEL couldn't be started!");
return false;
}

Console.WriteLine ("Making application visible");
app.Visible = true;

Console.WriteLine ("Getting the workbooks collection");
Workbooks workbooks = app.Workbooks;

Console.WriteLine ("Adding a new workbook");

try {
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);

} catch (System.IO.FileNotFoundException) {

Console.WriteLine("Always gets here.");
}
...

Nov 15 '05 #3

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

Similar topics

9
by: Ksenia Marasanova | last post by:
Hi, I have a little problem with encoding. Was hoping maybe anyone can help me to solve it. There is some amount of data in a database (PG) that must be inserted into Excel sheet and emailed....
2
by: Belinda | last post by:
Hello All I want to place a Excel workbook on the web server and create a URL link to it and when the user clicks on it to the URL/vbscript behind it must launch Excel on the client and open the...
11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
0
by: dgoel | last post by:
Hi, I Have a text file & I want to open it in excel sheet ( withou importing). I have written code for it, but it is not opening exce sheet. It opens the text file, but does not create a excel...
1
by: javzxp | last post by:
Hi I'd like to use C# to open an existing Excel workbook and save each worksheet it contains into a new Excel file. The name of each new Excel file should be the name of the worksheet copied...
3
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel...
3
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
0
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.