Word Document Format Type not Working

Hi,

I'm having a problem on saving the word document with a format type of "Docx". I tried to save the word document as "Docx".

Here's my Code on saving.

var saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Word Document (*.docx)|*.docx";

if (saveFileDialog.ShowDialog() == true)
{
     var document = new WordDocument();
     document.Save(saveFileDialog.FileName, FormatType.Docx);
     document.Close();
}

It appears that in actual file it was save as ".docx". but the problem is when I tried to open the file the ActualFileFormat returns "Word2013" not "Docx". even though i open it like this;

Here's my code on opening.

var openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Word Document (*.docx)|*.docx";
if(openFileDialog.ShowDialog() == true)
{
     var document = new WordDocument(openFileDialog.FileName, FormatType.Docx);
}

I really need the ActualFileFormat to be "Docx".

Hope you can help me.

Thank you!

PS: The MS Office installed in my laptop is Microsoft Office 2016.

Regards,

Alcher

1 Reply

SY Sethumanikkam Yogendran Syncfusion Team December 13, 2017 11:10 AM UTC

Hi Alcher,

Thank you for contacting Syncfusion support.

The following FormatType enumeration values of Essential DocIO denotes the DOCX file (*.docx), but differs based on the Microsoft Word application version in which created it.

     1. FormatType.Docx         – Denotes the DOCX files created by latest Microsoft Office version 2016.
     2. FormatType.Word2013 – Denotes the DOCX files created by Microsoft Office version 2013.
     3. FormatType.Word2010 – Denotes the DOCX files created by Microsoft Office version 2010.
     4. FormatType.Word2007 – Denotes the DOCX files created by Microsoft Office version 2007.

For example, if DOCX document created using Microsoft Word 2010 application, then app version will be mentioned as 14 in file level. So, DocIO returns the ActualFormatType value as “Word2010”. This is the expected behavior of ActualFormatType property.

If you are trying to save the document using ActualFormatType property of DocIO loaded Word document, then you can use the below code example.
 
The code example to save the document as DOCX file with the latest app version 16 (Word 2016 application). 
switch (document.ActualFormatType)
{
   
case FormatType.Docx:
   
case FormatType.Word2013:
   
case FormatType.Word2010:
   
case FormatType.Word2007:
       
// Saves as DOCX file with the latest app version 16 (Word 2016 application).
        document.Save(saveFileDialog.FileName, FormatType.Docx);
       
break;
}
 
The code example to save the document as DOCX file with the same app version as like input DOCX file. 
switch (document.ActualFormatType)
{
   
case FormatType.Docx:
   
case FormatType.Word2013:
   
case FormatType.Word2010:
   
case FormatType.Word2007:
       
// Saves as DOCX file with the same app version as like input DOCX file.
        document.Save(saveFileDialog.FileName, document.ActualFormatType);
       
break;
}
 

We have found a known issue in retrieving ActualFormatType property of Word document and this issue is already fixed in our latest Essential Studio 2017 Volume 4 Release v15.4.0.17. Kindly upgrade to latest version to resolve the reported issue “ActualFormatType property returns “Word2013”, instead of “Docx” for Microsoft Word 2016 application created DOCX file”.

You can download our latest Essential Studio 2017 Volume 4 Release v15.4.0.17 from the following link.
https://www.syncfusion.com/forums/134428/essential-studio-2017-volume-4-release-v15-4-0-17-is-available-for-download

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


Loader.
Up arrow icon