How to save DOCM to DOCX without removing macros using .NET

Hi,

I have a file with macros (inputFile.docm) and I want to save it as DOCX.
When doing that, Aspose Words throw an exception because the inputfile contains macros. It is right, but if you do the same with Aspose.Cells or Aspose.Diagram, there is no problem. Those components can remove the macros and save it as XLSX or VSDX without throwing an error.
The inputFile.docm is in the zip file.
Thanks.

Elements.zip (3.7 MB)

@julien.mevel.isilog

Your document contains the macros. So, to avoid this exception, please save document to DOC or DOCM save format. If you want to save the document to DOCX file format, you can remove the macros from the document using Document.RemoveMacros method as shown below.

Document doc = new Document(MyDir + "inputFile.docm");
doc.RemoveMacros();
doc.Save(MyDir + "out.docx");

Hi,

I know that it is possible to do that, but as I told you we should be able to do it like Word does.
Also, Aspose.Cells, Aspose.Diagram do not have this problem. Both of them can save a file with macros in a free macro format without removing the macros first.
Thanks.

@julien.mevel.isilog

Please note that Aspose.Words mimics the behavior of MS Word. If you convert your DOCM to DOCX using MS Word, it does not allow to save DOCX with macros. Please check the attached image for detail. docm-to-docx.png (23.1 KB)

Hi,

I agree with you, but if you answer YES, the file is saved as macro-free, so with Word it’s possible to save it without removing macros first.
Thanks.

@julien.mevel.isilog

Please note that MS Word removes the macros before saving the document to DOCX format. You can achieve this requirement by calling Document.RemoveMacros method.

Yes I agree with you, but as I told you Aspose.Cells can save XLSM to XLSX without removing the macros before. And you can see that Excel dispaly the same message as Word when saving XLSM to XLSX.
So I do not understand why Aspose.Words can not save DOCM as DOCX without us removing the macros. I think that we should be able to have the same “mimics” as Aspose.Cells.
Thanks.

@julien.mevel.isilog

Perhaps, it is an issue with Aspose.Cells. Please try the latest version of Aspose.Cells 20.5.0.

If you still face problem, please attach the following resources here for testing:

  • Your input XLSM document.
  • Please attach the output XLSX file that shows the undesired behavior.
  • Please attach the expected output XLSX file that contains the macros.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.