MsWordVersion enumeration

MsWordVersion enumeration

Allows Aspose.Wods to mimic MS Word version-specific application behavior.

Members

NameDescription
WORD2000Optimize Aspose.Words behavior to match MS Word 2000 version.
WORD2002Optimize Aspose.Words behavior to match MS Word 2002 version.
WORD2003Optimize Aspose.Words behavior to match MS Word 2003 version.
WORD2007Optimize Aspose.Words behavior to match MS Word 2007 version.
WORD2010Optimize Aspose.Words behavior to match MS Word 2010 version.
WORD2013Optimize Aspose.Words behavior to match MS Word 2013 version.
WORD2016Optimize Aspose.Words behavior to match MS Word 2016 version.
WORD2019Optimize Aspose.Words behavior to match MS Word 2019 version.

Examples

Shows how to optimize the document for different versions of Microsoft Word.

def optimize_for():
    doc = aw.Document()
    # This object contains an extensive list of flags unique to each document
    # that allow us to facilitate backward compatibility with older versions of Microsoft Word.
    options = doc.compatibility_options
    # Print the default settings for a blank document.
    print('\nDefault optimization settings:')
    print_compatibility_options(options)
    # We can access these settings in Microsoft Word via "File" -> "Options" -> "Advanced" -> "Compatibility options for...".
    doc.save(ARTIFACTS_DIR + 'CompatibilityOptions.optimize_for.default_settings.docx')
    # We can use the OptimizeFor method to ensure optimal compatibility with a specific Microsoft Word version.
    doc.compatibility_options.optimize_for(aw.settings.MsWordVersion.WORD2010)
    print('\nOptimized for Word 2010:')
    print_compatibility_options(options)
    doc.compatibility_options.optimize_for(aw.settings.MsWordVersion.WORD2000)
    print('\nOptimized for Word 2000:')
    print_compatibility_options(options)

def print_compatibility_options(options: aw.settings.CompatibilityOptions):
    """Groups all flags in a document's compatibility options object by state, then prints each group."""
    for enabled in (True, False):
        print('\tEnabled options:' if enabled else '\tDisabled options:')
        for opt in dir(options):
            if not opt.startswith('__') and (not callable(getattr(options, opt))) and (getattr(options, opt) == enabled):
                print(f'\t\t{opt}')

See Also