Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Unable to open worksheet when called through a function

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Unable to open worksheet when called through a function

Try this:
Open a cmd prompt and type:

regsvr32 "%windir%\system32\cdosys.dll

Regards,

Michael Arch.

Please rate this answer



"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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Unable to open worksheet when called through a function

Hi Michael

Thanks for your answer but I am still getting the same error and its random.
I get it 1 time for every 300 times or 400 times I run the code

"Michael" wrote:

Try this:
Open a cmd prompt and type:

regsvr32 "%windir%\system32\cdosys.dll

Regards,

Michael Arch.

Please rate this answer



"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

Reply
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
unable to view all open excel worksheet from window Ileen Excel Discussion (Misc queries) 2 January 3rd 09 12:52 AM
workbook_open not being called when I open the excel file Hany Excel Programming 3 April 8th 06 01:34 PM
When I open a workbook, another one called Book1 is also opened. W Ian@MarlandLtd Excel Discussion (Misc queries) 2 November 9th 05 09:36 AM
function called from worksheet and bad result! @lan Excel Programming 6 August 3rd 04 03:12 PM
Unable to get the NormDist of the Worksheet Function Stef C Excel Programming 1 November 8th 03 03:26 PM


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

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

About Us

"It's about Microsoft Excel"