-
March 9th, 2015, 06:39 AM
#1
Copying the data from one workbook to another Work book, cauing the error-COM class
Hi all,
I need to copy all the sheets from Workbook1 to another Workbook2 one by one.
I wrote the code, and i got the error at 1st line :-(.
How to resolve this error?
The error is -
Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
I have written the following code...
Code:
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Open a file into the first book.
Dim excelWorkbook0 As Workbook = New Workbook("D:\PSR Conversion to VB.net\Book1.xlsx")
'Create another Workbook.
Dim excelWorkbook1 As Workbook = New Workbook()
'Copy the first sheet of the first book into second book.
excelWorkbook1.Worksheets(0).Copy(excelWorkbook0.Worksheets(0))
'Save the file.
excelWorkbook1.SaveAs("C:\FinalBook.xls")
end sub
Also if anyone knows to do it any other way, i will be glad to know it.
Thanks in advance
Regards
Soni
Last edited by SeemsP; March 9th, 2015 at 06:43 AM.
-
March 9th, 2015, 01:08 PM
#2
Re: Copying the data from one workbook to another Work book, cauing the error-COM cla
Have you set the correct references to the correct Excel version?
-
March 9th, 2015, 01:26 PM
#3
Re: Copying the data from one workbook to another Work book, cauing the error-COM cla
Originally Posted by HanneSThEGreaT
Have you set the correct references to the correct Excel version?
Hi HannesTheGreat,
I followed the following steps:
1. On the top -->Project --> Add References --> from COM section ->Microsoft Excel 14.0 object Library.
Humm
and i am using MS Excel 2010.
Can guide me where i went wrong? Please...
Regards
Soni
-
March 10th, 2015, 02:22 AM
#4
Re: Copying the data from one workbook to another Work book, cauing the error-COM cla
Hi Friends,
Can any one please help me out with this...
I need to copy one work sheet without loosing the formatting, to another Workbook..
If you have some useful links , please do provide me.... i need it , its necessary
Regards
Prity
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|