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

Free Support Forum - aspose.com

How to preserve macros in docs and spreadsheet during conversion using Aspose.Words

Hi there ,


I am trying to convert a .doc to .docx. But after converison I lost the macros in the document.
Can you share the code snippet to perform the same in c# .
I am using Aspose.words 17.4 from nuget.

Sincerely
Harshit

Hi Harshit,


Thanks for your inquiry. Please note DOCX is macro free document along with DOTX and FlatOpc (Word 2007 XML) formats. All other MS Word formats DOCM, DOTM, DOC, RTF, WML (Word 2003 XML) can contain macros. So if you want to preserve macros in your output document, you should use DOCM (macro-enabled DOCX format) instead of DOCX.


<o:p></o:p>

You can check whether Document contains macros using HasMacros property and save document accordingly. However, if you would like to save your document as DOCX, you should remove macros

<o:p> </o:p>

Document doc = new Document(“in.doc”);<o:p></o:p>

doc.RemoveMacros();<o:p></o:p>

doc.Save(“out.docx”);


Please feel free to contact us for any further assistance.


Best Regards,