Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example
Code Block
csharp
csharp
titleC#
//An example of copying worksheets between workbooks
ExcelApplication xla = new ExcelApplication();
Workbook wbSource = xla.Open("sourceWorkbook");
Workbook wbDest = xla.Open("destWorkbook");

//Copy a worksheet from the source workbook into the destination workbook
//Insert the copy at the beginning of the workbook
Worksheet wsToCopy = wbSource.Worksheets([0)];
wbDest.Worksheets.CopySheet(wsToCopy, 0, wsToCopy.Name);
Code Block
vbnet
vbnet
titlevb.net
'An example of copying worksheets between workbooks
Dim xla As ExcelApplication = new ExcelApplication()
Dim wbSource As Workbook = xla.Open("sourceWorkbook")
Dim wbDest As Workbook = xla.Open("destWorkbook")

'Copy a worksheet from the source workbook into the destination workbook
'Insert the copy at the beginning of the workbook
Dim wsToCopy As Worksheet = wbSource.Worksheets[(0])
wbDest.Worksheets.CopySheet(wsToCopy, 0, wsToCopy.Name)