View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
zoddiax zoddiax is offline
external usenet poster
 
Posts: 8
Default Simple Excel Problem

Please help me out with this Simple Excel Problem

"zoddiax" wrote:

I am trying to open worksheet but it gives me the following error. This error
dosent occur every time. Its random. That's why I have put my code in try
block.

System.Runtime.InteropServices.COMException (0x8002801D): Library not
registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))
at Microsoft.Office.Interop.Excel.Sheets.get__Default (Object Index)

Following is my code snippet

private void PasteData(string sSheet)
{
try
{
/* Open the corresponding sheet in the WorkSheet */
xlSheetScript =
(Excel.Worksheet)xlBookScript.Worksheets[sSheet];

/* Find the last row in that sheet */
for (iCount = 400; iCount 0; iCount--)
{
xlRange = (Excel.Range)xlSheetScript.Cells[iCount, 2];
if (xlRange.Value2 != null)
{
break;
}
}

Any help will be greatly appreciated.
Thanks