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

Free Support Forum - aspose.com

Removing compatibility mode from generated document using Aspose

Hi Team,

Giving some brief about what we are trying to achieve. We have template defined in xml format. Using this xml template we have to generate letter out of it. For this we are using Aspose. Now the problem is when we open the generated letter document it opens compatibility mode.

We have found one option in MSWord which saves the document in docx/docm format and opens it normal (Without compatibility) mode. This same thing we want to do it using Aspose. Below are the step we followed in MSWord.

Steps we have followed:

  1. Created one xml document. Let’s say Template.xml
  2. Now open this xml file with MSWord and added some macro code or we can just add some text to it and save it.
  3. Now click on save as option and select .docm or .docx format. We will get “Maintain compatibility with previous version of word”. If we uncheck this check box then document opens up without compatibility mode.

Where can we set this “Maintain compatibility with previous version of word” option in Aspose so that we can get rid of compatibility option.

your support will be much appreciated.

Regards,
Rajesh Prajapati

@rajesh.prajapati

Unfortunately, Aspose.Words does not provide this feature. However, you can use CompatibilityOptions.OptimizeFor method to optimize the document to specific MS Word version.

Could you please share complete detail of your use case along with input and expected output documents? Please also share which MS Word version you are using. We will then provide you more information about your query.

@tahir.manzoor

We want to generate word document(docm) from xml file. We are able to do so but when we open this document we get compatibility mode on top of it. We don’t want this to display it in compatibility mode.

To create xml file we simple open black xml file with word and add some content to it and save it. We are using this xml to generate word document.

We are using ms word 2010.

@rajesh.prajapati

Have you tried the CompatibilityOptions.OptimizeFor method as shown below?

doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010);

If you still face problem, please ZIP and attach your input, problematic output and expected output documents. We will investigate the issue and provide you more information on it.

Thanks @tahir.manzoor

I tried with doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010); but it still opens in compatible mode.

My issue got resolved with below code

Aspose.Words.Saving.OoxmlSaveOptions ooxmlSaveOptionsDoc = new Aspose.Words.Saving.OoxmlSaveOptions(SaveFormat.Docm);
ooxmlSaveOptionsDoc.Compliance = Aspose.Words.Saving.OoxmlCompliance.Iso29500_2008_Transitional;
            
Aspose.Words.Document docType = new Aspose.Words.Document(filepath);
docType.CompatibilityOptions.OptimizeFor(Aspose.Words.Settings.MsWordVersion.Word2010);
docType.Save("word.docm", ooxmlSaveOptionsDoc); 

Thanks a lot for you support

@rajesh.prajapati

It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

A post was split to a new topic: Compatibility Mode in Office365