Copy workbook not copying VBA

The following code taken from the Aspose Cells forum does not copy the VBA, and according to the forum answer it should:

Private Sub Copy_WorkBook(ByVal WBIn As String, ByVal WBOut As String)

'Instantiate a new Workbook object.

Dim WB1 As Workbook

Dim WB2 As New Workbook

WB1 = New Workbook(Fldr & WBIn)

WB2.Copy(WB1)

WB2.Save(FldrOut & WBOut)

End Sub

The source XLT template WBIn has VBA behind sheet number 1. The output XLS does not.

Hi,

Please attach your input and output files here, we will check your issue soon.

By the way, could you try our latest version/fix v5.3.2.7 if it works fine.

Thank you.

I upgraded to the version you stated, and the results are the same. Spreadsheet in and out are attached.

Hi,

I tried your code using your template xlt file with Aspose.Cells for .NET v5.3.2.7 and it works fine. The VBA codes are there for “Sheet2” and “Sheet3” in the generated XLS file. Here is my sample code:
Dim WB1 As New Workbook(“e:\test2\UPSCompControlSheet.xlt”)
Dim WB2 As New Workbook()
WB2.Copy(WB1)
WB2.Save(“e:\test2\outUPS.xls”, SaveFormat.Excel97To2003)

I have also attached the output XLS file for your reference.

Please make sure that you are using the latest fix i.e. v5.3.2.7.

Thank you.