Hi Team,
We are facing issues with copying of sheets between workbooks. Request you to please help.
We have requirement to copy all sheets from one workbook to another. The sheets have various shapes like button, dropdown etc and a number of named ranges. The problem we are facing is the shapes are not getting copied properly. It is getting misplaced or overlapped at some places. Also the named ranges are losing the values.
I am using the following codes to copy sheets. please suggest is this the right way
Private Sub CopySheets()
''Copy the sheets from tmpWorkBook File to the new file
For index As Integer = 0 To SheetListCol.Count - 1
If Not (SheetListCol.Item(index).ToString() = “Index”) Then
Dim cpOptions As New Aspose.Cells.CopyOptions
cpOptions.CopyNames = True
cpOptions.CopyInvalidFormulasAsValues = True
Dim copySheet As Aspose.Cells.Worksheet = tmpWorkBook.Worksheets.Add(SheetListCol.Item(index).ToString())
copySheet.Copy(newWorkBook.Worksheets(SheetListCol.Item(index).ToString()), cpOptions)
If copySheet.IsProtected Then
copySheet.Unprotect(“XXXX”)
End If
End If
Next
End Sub
Thanks
Anish