Document Version

Hello

I am tring to set the Version of a docx file, I have done this using the BuiltInDocumentProperties.Version but when it is read the value is always 786432. here is my sample code:

// open original doc
string testFileName = @"D:\temp\Version\versiontest.docx";
var doc = new Aspose.Words.Document(testFileName);

// update the version
int newVersion = 10;
doc.BuiltInDocumentProperties.Version = newVersion;
doc.Save(testFileName, Aspose.Words.SaveFormat.Docx);

// open and read the new version
var newversionDoc = new Aspose.Words.Document(testFileName);
Console.WriteLine(newversionDoc.BuiltInDocumentProperties.Version);

please can you tell me the correct way to set the version or fix the bug.

thank you

karrim

Hi Karrim,

Thanks for your inquiry. BuiltInDocumentProperties.Version property represents the version number of the application that created the document.

When a document was created by Microsoft Word, then high 16 bit represent the major version and low 16 bit represent the build number.

In your case, I suggest you please use the Document.CustomDocumentProperties as shown below to set the custom property e.g version. Hope this helps you.

var doc = new Aspose.Words.Document();
int newVersion = 10;
doc.CustomDocumentProperties.Add("Version", newVersion);
doc.Save(MyDir + "Out.docx", Aspose.Words.SaveFormat.Docx);
// open and read the new version
var newversionDoc = new Aspose.Words.Document(MyDir + "Out.docx");
Console.WriteLine(newversionDoc.CustomDocumentProperties["Version"]);