RPC_E_SERVERFAULT Error on simple Excel 2003 automation task

K

Khonsort

Hello,

I've spent the last 2 days to try to run a simple c# program which just open
an Excel 2003 Workbook and try to copy one of his Worksheet at the end of is
Sheets collection. That don't work ! I just get the error message :

Code SnippetLe serveur a généré une exception. (Exception de HRESULT :
0x80010105 (RPC_E_SERVERFAULT))
à Microsoft.Office.Interop.Excel._Worksheet.Copy(Object Before, Object
After)
à ConsoleApplicationExcelAutomation.Program.Main(String[] args) dans
C:\Developpements\VS2005\Tests\ConsoleApplicationExcelAutomation\Program.cs:ligne 27


Environment configuration

Windows XP SP2 French
Excel 2003 SP3 (11.8169.8172) French
Here is the complete source code :


=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-==-=-=-=-
using System.Collections.Generic;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;

namespace ConsoleApplicationExcelAutomation {

class Program {

static void Main( string[] args ) {

Excel._Application xlApp = null;

try {
xlApp = new Excel.Application();
xlApp.Visible = true;

Excel._Workbook xlBook = null;

try {
xlBook = xlApp.Workbooks.Open( @"C:\Documents and
Settings\fprevost\Mes documents\Classeur_test_PA2003.xls",
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value );

try {
( (Excel._Worksheet) xlBook.Sheets[1] ).Copy( Missing.Value,
xlBook.Sheets[2] );
}
catch ( Exception ex ) {
System.Console.Out.WriteLine( ex.Message );
System.Console.Out.WriteLine( ex.StackTrace );
}

System.Console.In.ReadLine();
}
finally {
if ( xlBook != null ) {
xlBook.Close( false, Missing.Value, Missing.Value );
xlBook = null;
}
}
}
catch ( Exception ex ) {
System.Console.Out.WriteLine( ex.Message );
System.Console.Out.WriteLine( ex.StackTrace );

System.Console.In.ReadLine();
}
finally {
if ( xlApp != null ) {
xlApp.Quit();
xlApp = null;
GC.Collect();
}
}
}
}
}

=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-==-=-=-=-

Can anybody try to complie and run successfully this code ? or explain me
why that goes wrong ?



Thanks in advance for any help.
 
K

Khonsort

Hi,



As last solution before re-installing my computer, cause this application
works fine on an newly installed computer with Excel 2007 (my computer hosted
Office 2000 before I uninstall it for 2003), I've cleaned manually my
registry under the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office". And...



my program works fine on my station. I'll just reboot it before open
Champagne.



I hope that solution will be the right one and will be usefull for somebody
else.



Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top