We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Workbook.SaveToStream() removes VBA

I have noticed that Workbook.SaveToStream() removes VBA macros; is this by design?

Workbook.Save(Stream, SaveFormat) retains macros if the save format is an .xl?m

I am using Aspose.Cells V7.0.3.1

Hi,

This might be a bug.

Please provide us your file so that we could look into this issue and fix it asap.

mshakeel.faiz:
Hi,

This might be a bug.

Please provide us your file so that we could look into this issue and fix it asap.

This is the VB code. The database is too big to attach, and there is a related windows service that is not necesary.

The problematic code is in FAWGenerator.vb, line 1099, currently commented out & replaced by lines 1097-1098.

Really, just load the template and save it to a stream, and the VBA is gone in the final output. This code works with the workbook.save, but not with the workbook.savetostream.

Hi,


Well, for your information, you should not use Workbook.SaveToStream() method when working with XLSX, XLTM, XLSM etc. file formats (Excel 2007/2010 file formats). The Workbook.SaveToStream() method only works for XLS files (Excel 97-2003) files.

So, you are doing fine:

m_IntermediateTemplate = New MemoryStream()
acWBTemplate.Save(m_IntermediateTemplate, Aspose.Cells.SaveFormat.Xltm)



Amjad,

Thanks for that information.

It would be nice if these sorts of things were documented in the help files - I have noticed that while every member of the classes are documented, a comprehensive description and/or details such as this are missing more often than not.

Monty Wild.

Hi,


Thanks, we will surely add more description for SaveToStream in the API Reference pages.

Have a good day!