Save document with the version of Word

When we save file as docx then I open and check the version by this way
https://superuser.com/questions/1144378/how-can-i-know-with-which-microsoft-word-version-a-docx-file-was-saved
Then the result file is Word 2007 ( appversion 12.000)
So do we have anyway to save the output as Word version 2019 ?

@TanPham You can use CompatibilityOptions.OptimizeFor method before saving the document:

Document doc = new Document(@"C:\Temp\in.docx");
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2019);
doc.Save(@"C:\Temp\out.docx");

image.png (19.8 KB)

after I try to do that, the app version still 12.0000 it mean word 2007

@TanPham You can write this value in BuiltInDocumentProperties.Version.

Document doc = new Document();
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2019);
// MS Word 2019 version whrites 17.000 version.
doc.BuiltInDocumentProperties.Version = (17 << 16);
doc.Save(@"C:\Temp\out.docx");