Adding/copying Worksheet to Excel

  • Thread starter Thread starter Nicolas
  • Start date Start date
N

Nicolas

I got 10 worksheets in workbook Master (file master.xls) and I wand to copy
them to the workbook B (file b.xls).
How can I do this? I need to this for few thousand files.
 
Nicolas said:
I got 10 worksheets in workbook Master (file master.xls) and I wand to copy
them to the workbook B (file b.xls).
How can I do this? I need to this for few thousand files.

This is code sample that shows how to add new worksheet in vb.net
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet

obook = oexcel.Workbooks.Add
osheet = oexcel.Worksheets(1)
osheet.Name = "TEST1"
osheet.Range("A1:AZ400").Interior.ColorIndex = 2
osheet.Range("A1").Font.Size = 12
osheet.Range("A1").Font.Bold = True
osheet.Range("A1:I1").Merge()
osheet.Range("A1").Value = "Excel Automation With Charts"
osheet.Range("A1").EntireColumn.AutoFit()

osheet.Range("A2").Font.Size = 12
osheet.Range("A2").Font.Bold = True
osheet.Range("A2:I2").Merge()
osheet.Range("A2").Value = "Excel Automation With Charts"
osheet.Range("A2").EntireColumn.AutoFit()

osheet = oexcel.worksheets(2)
osheet.Name = "TEST2"
osheet = oexcel.worksheets(3)
osheet.Name = "TEST3"

'add worksheet
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
osheet.Name = "TEST42222222222222222"
osheet.Move(After:=obook.Worksheets(obook.Worksheets.Count))

obook.SaveAs("C:\TEST1.xls")
obook.Close()
obook = Nothing
oexcel.Quit()
oexcel = Nothing


http://vbdotnettutorial.blogspot.com/search/label/Excel
 
Back
Top