Using IncludeText in dot based template results in a word security message

Hi,
we are using the latest version of Aspose.Words for Java. It seems we have found a bug with handling INCLUDETEXT fields when saving a dot based template as docm file.

Problem:
We have a dot template that contains an IncludeText-function. We save this file as docm per Aspose.
Opening the file will result in a security message in Word (see Word Security Message.png)

If we do the same with a dotm based template, everything is fine. No security message in Word is shown.

Example code for reproducing the scanario:

String path = "c:\\Test\\";
String simpleFileName = "TestIncludeText";
 
Document documentDOT = new Document(path + simpleFileName + ".dot");
documentDOT.updateFields();
documentDOT.save(path + simpleFileName + " DOT Aspose.docm");
 
Document documentDOTM_ok = new Document(path + simpleFileName + ".dotm");
documentDOT.updateFields();
documentDOTM_ok.save(path + simpleFileName + " DOTM Aspose.docm");

Note:
In Version 22.4 this works fine - in Version 22.5 the error occured for the first time.

Test files:
Test.zip (136.8 KB)

  • Word Security Message.png - Message in Word
  • Example.doc - Word document that will be included and must be stored in c:\Test
  • TestIncludeText.dot - DOT template that contains an IncludeText-field with reference to c:\Test\Example.doc
  • TestIncludeText DOT Aspose.docm - Generated file per Aspose based on DOT → security message
  • TestIncludeText.dotm - DOTM variant of template that contains an IncludeText-field with reference to c:\Test\Example.doc
  • TestIncludeText DOT Aspose.docm - Generated file per Aspose based on DOTM → ok

Is there any possibility in coding to avoid this result?

Best regards
Matthias

@curmas INCLUDETEXT in DOT template is marked as dirty so MS Word updates it on open and warns. You can reset isDirty flag to avoid this:

Document doc = new Document("C:\\Temp\\TestIncludeText.dot");
doc.updateFields();
// Mark all field as not dirty.
for(Field f : doc.getRange().getFields())
    f.isDirty(false);
doc.save("C:\\Temp\\out.docm");

Hello @alexey.noskov,

perfect, that works well. Thank you for this tip. It really helps me a lot.

With kind regards
Matthias

1 Like