Home All Groups Group Topic Archive Search About
Author
26 Jun 2006 3:34 AM
Ishan Bhalla
Hello,

Am not sure if i have put this in the wrong discussion group.

I have 2 workbooks with 1 worksheet each. I want to merge the workbooks into
one. Any idea how to do it? I am using VB.net 2003

Thanks in advance
regards
Ishan

Author
26 Jun 2006 6:39 AM
Ahmed
Try the following code. I just wrote it but didn't test it:

        Dim excelApp As New Excel.Application
        excelApp.Workbooks.Open("c:\book1.xls")
        excelApp.Workbooks.Open("c:\book2.xls")

excelApp.Workbooks(1).Sheets.Add(excelApp.Workbooks(2).Sheets.Item("Sheet1"))
        excelApp.Workbooks(1).Save()
        excelApp.Workbooks.Close()

You need to include a reference to the excel library.

Cheers,
Ahmed
Ishan Bhalla wrote:
Show quoteHide quote
> Hello,
>
> Am not sure if i have put this in the wrong discussion group.
>
> I have 2 workbooks with 1 worksheet each. I want to merge the workbooks into
> one. Any idea how to do it? I am using VB.net 2003
>
> Thanks in advance
> regards
> Ishan