Free Support Forum - aspose.com

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)


#9

Hi,

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

Thank you,
Lukasz


#10

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


#11

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


#12

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


#13

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


#14

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


#15

I understand. Thank you for checking :slight_smile: