Saving as .dot template with macros


#1

Hi,

I have some questions regarding macros in Aspose.

Please see the two templates attached. macros.zip (33.4 KB)
When I open “beforeMacrosRemoved” in Microsoft Word I cannot see any macros, but when I open it using Aspose and after some operations I want to save it as .dot/.dotx Aspose does not allow me (throwing error).

            Document document = new Document(MyDir + "beforeMacrosRemoved.dot");

            document.Save(MyDir + "beforeMacrosRemoved.dot");

When I check if it has macros before saving and remove them, then I cant save the document as .dot/.dotx. Then when I open this document “afterMacrosRemoved” in Microsoft Word it looks the same as “beforeMacrosRemoved”. When I open it using Aspose I can save it without RemoveMacros logic.

            Document document = new Document(MyDir + "beforeMacrosRemoved.dot");
            if(document.HasMacros)
                document.RemoveMacros();
            document.Save(MyDir + "beforeMacrosRemoved.dot");

If I open the two documents as xml they both have this attribute with yes - w:macrosPresent=“yes”.

Can you tell me why Aspose sees the first document, as if it had macros?

Thank you,
Łukasz


#2

@acturisaspose

Thanks for your inquiry. We have tested your provided documents using the latest version of Aspose.Words 18.11 and found no issue. Documents are saving properly without any exception. Please make sure you are using the latest version of Aspose.Words.

Please check document for your reference. beforeMacrosRemoved_18.11.zip (9.8 KB)


#3

Hi,

Thank you for your answer, when I try to save it as .dotx I cannot, I get the error.

Document document = new Document(MyDir + "beforeMacrosRemoved.dot");

document.Save(MyDir + "beforeMacrosRemoved.dotx");

Thanks,
Lukasz


#4

@acturisaspose

Thank you for patience. Please remove the Macros from document then save to .dotx.
Here is the sample code to remove Macros from Document.

 Document document = new Document(MyDir + "beforeMacrosRemoved.dot");
            if(document.HasMacros)
                document.RemoveMacros();
            document.Save(MyDir + "beforeMacrosRemoved_18.11.dotx");

Please check document for your reference.beforeMacrosRemoved_18.11.zip (16.6 KB)


#5

Hi,

Thank you for your answer, however, this is not what I asked about. Could you please refer to my first message in this topic and question from the message?

Thank you,
Lukasz


#6

@acturisaspose

We have checked your shared document “beforeMacrosRemoved.dot” and found that Macros exist in the document, but disabled due to security reasons and that is why Aspose.Words throws the error and not allowing to save the document to .dotx format. Kindly check the following links for your reference.

Content is disabled
Security Warning


#7

Hi,

Thank you for your response. I am not able to access the links. Do I need some software installed to view them?

Could you check them?

Thanks,
Lukasz


#8

@acturisaspose
Thanks for your inquiry. Please check the attached screenshots for your reference.ScreenShots.zip (56.4 KB)