LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copy a worksheet throws "Exception from HRESULT: 0x800A03EC."

Hi,
While iam trying to copy a worksheet from one file to another file in C#,
VS.NET 2003 i get error message saying: "Exception from HRESULT:
0x800A03EC."

The Exact Code i used is:
Excel.Application xlApp1 = new Excel.ApplicationClass();
Excel.Application xlApp2 = new Excel.ApplicationClass();
object missing = Type.Missing;

xlApp1.Workbooks.Open(System.Windows.Forms.Applica tion.StartupPath +
@"\Reports.xls" ,
missing , missing, missing, missing, missing,missing, missing, missing,
missing, missing, missing, missing, missing, missing);
xlApp2.Workbooks.Open(System.Windows.Forms.Applica tion.StartupPath +
@"\Template.xls" ,
missing , missing, missing, missing, missing,missing, missing, missing,
missing, missing, missing, missing, missing, missing);

Excel.Workbook xlSrcBook;
Excel.Workbook xlDestBook;

xlSrcBook = xlApp2.ActiveWorkbook as Workbook;
xlDestBook = xlApp1.ActiveWorkbook as Workbook;

try
{
(xlSrcBook.Sheets[2] as
Worksheet).Copy(missing,xlDestBook.Sheets[xlDestBook.Sheets.Count]);
xlApp2.Visible = true;
}
catch(Exception ex)
{
MessageBox.Show(this,ex.Message);
}
finally
{
xlSrcBook.Saved = true;
xlDestBook.Saved = true;
xlSrcBook.Close(missing,missing,missing);
xlDestBook.Close(missing,missing,missing);
xlApp1.Quit();
xlApp1 = null;
xlApp2.Quit();
xlApp2 = null;
}

Can someone please help me in finding out the mistake ?
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"_Fill" and "_Key1" is contained in the worksheet I want to copy.. CWP Excel Discussion (Misc queries) 1 April 6th 10 06:08 PM
Exception from HRESULT: 0x800A03EC nano2k New Users to Excel 0 July 21st 06 12:15 PM
Exception from HRESULT: 0x800A03EC. at Microsoft.Office.Interop.Excel.WorkbookClass.get_VBProject() [email protected] Excel Programming 0 April 11th 06 04:40 PM
HRESULT: 0x800A03EC setting DataSource for pivot tables. [email protected] Excel Programming 1 January 18th 06 08:59 AM
Chart.Export throws COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC. Steven Excel Programming 1 November 5th 03 06:59 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"