Saving as .dot template with macros

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

@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)

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

@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)

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

@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

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

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

Hi,

Thank you for your response. Could you tell us how we can find the macro in the template itself?

Thank you,
Lukasz

@acturisaspose

Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have already logged this feature request as WORDSNET-3714 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

Hi,

Thank you for your response.

Could you also tell me how I can find the macro in the document itself when opening it with Microsoft Word? I cannot see the macro anywhere.

Thank you,
Lukasz

@acturisaspose

Please click on Developer menu visible on your Ribbon if you are using MS Word 2007 or above, if you are using MS Word 2003 click on Tools menu and then click on the Macros button and it should show you any macros that are available to run.

If you do not see the Developer menu, you can add it: File> Options> Customize Ribbon> Move Developer to the right pane and make sure it is checked.

Hope, this helps.

Hi,

Thank you. This is what I did and unfortunately I could not find any macro. Can you see any macros in the document?

Thank you,
Lukasz

@acturisaspose
Unfortunately, I also could not find any Macro in the document. There might be some Private macros or macros taking parameters that are not visible but this is the way to check Macros in document.

I understand. Thank you for checking :slight_smile:

The issues you have found earlier (filed as WORDSNET-3714) have been fixed in this Aspose.Words for .NET 19.6 update and this Aspose.Words for Java 19.6 update.