I have a Microsoft Word Document (docx) and I use Open XML SDK 2.0 Productivity Tool to generate C# code from it.
I want to programmatically insert some database values
You need to get rid of the Rsid information. According to this page Rsid information
enables merging of two documents that have forked.
You need to install in order to run the sample code below. The easiest way to do that is to run the following in the Package Manager Console
Install-Package OpenXmlPowerTools
Then you will be all set to run the following code. (Assuming that you already have a "Test.docx" file added to your document. If you are using Visual Studio, you need to make sure that you have a copy of the file in either the Debug or Release folder according to your build mode.)
//Sample code to remove Rsid information from a "Test.docx" document
using (WordprocessingDocument doc = WordprocessingDocument.Open("Test.docx", true))
{
SimplifyMarkupSettings settings = new SimplifyMarkupSettings
{
RemoveRsidInfo = true
};
MarkupSimplifier.SimplifyMarkup(doc, settings);
}
This will remove Rsid information that may get in the way in the process of manipulating Word files.