We have inherited a ton of code written in C# on .NET 2.0 in Visual Studio 2005. The backend database is MS SQL server 2000. We have migrated the code to C# on .NET 4.0 in Visual Studio 2010 and can compile and build. The problem is the old code used the Microsoft.Interop.Office.Word library to allow us to generate server-side reports using mail merge and macro-embedded templates. We now understand that Visual Studio 2010 does not support server side VBA or C# MS Word application work. So we have downloaded Open XML 2.0. The documentation is beyond frustrating. And the myriad posts we find on the web speak to document creation from scratch, little about mail merging or running enabled macros in .dotm files, etc and most of them deal with Open XML 1.0.
Can I convert a .dotx file to a .xml file in MS Word, then just use C# and the Open XML API to load up that .xml file and embed the variable data pulled from the database? It seems absolutely crazy to construct an EXISTING .xml file (that is a 30 page report) dynamically in code each time the report is run. Am I missing something?
If someone has successfully done this, and example with C# code would be really helpful. Thanks, Emily