Skip to content

Commit ce67eb4

Browse files
Merge pull request #1565 from Syncfusion-Content/hotfix/hotfix-v23.1.36
DOCINFRA-2341_merged_using_automation
2 parents b2fb1e6 + 3afb538 commit ce67eb4

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

File-Formats/DocIO/word-file-formats.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync
637637

638638
### Saving Word document with compatibility
639639

640+
#### Maintain existing compatibility
640641
The following code shows, how to save Word document with same word version compatibility
641642

642643
{% tabs %}
@@ -738,6 +739,59 @@ document.Close();
738739

739740
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Word-file-formats/Save-Word-with-compatibility).
740741

742+
#### Save Word in old compatibility
743+
744+
The following code shows, how to save Word document in old compatibility using DocIO.
745+
{% tabs %}
746+
747+
{% highlight c# tabtitle="C# [Cross-platform]" %}
748+
749+
//Create an instance of WordDocument.
750+
using (WordDocument document = new WordDocument())
751+
{
752+
document.EnsureMinimal();
753+
//Append paragraph.
754+
document.LastParagraph.AppendText("Hello World");
755+
//Sets the compatibility mode to Word 2007.
756+
document.Settings.CompatibilityMode = CompatibilityMode.Word2007;
757+
//Create FileStream to save the Word file.
758+
using (FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
759+
{
760+
//Save the Word file.
761+
document.Save(outputStream, FormatType.Docx);
762+
}
763+
}
764+
765+
{% endhighlight %}
766+
{% highlight c# tabtitle="C# [Windows-specific]" %}
767+
768+
//Create an instance of WordDocument.
769+
using(WordDocument document = new WordDocument())
770+
{
771+
document.EnsureMinimal();
772+
document.LastParagraph.AppendText("Hello World");
773+
//Sets the compatibility mode to Word 2007.
774+
document.Settings.CompatibilityMode = CompatibilityMode.Word2007;
775+
document.Save("Sample.docx");
776+
}
777+
778+
{% endhighlight %}
779+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
780+
781+
'Create an instance of WordDocument.
782+
Using document As New WordDocument()
783+
document.EnsureMinimal()
784+
document.LastParagraph.AppendText("Hello World")
785+
' Sets the compatibility mode to Word 2007.
786+
document.Settings.CompatibilityMode = CompatibilityMode.Word2007
787+
document.Save("Sample.docx")
788+
End Using
789+
790+
{% endhighlight %}
791+
{% endtabs %}
792+
793+
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Word-file-formats/Save-Word-in-old-compatibility/.NET).
794+
741795
### Open a Word (*.doc) document containing incremental save information
742796

743797
Essential DocIO process the content that are preserved in the last complete save operation alone from a Word (.doc) document and it doesn't process the incremental save information. Hence it throws "Complex format is not supported" exception when attempting to open a Word (.doc) document containing incremental save information.

0 commit comments

Comments
 (0)