1

I want to convert or typecaste an existing DocX word doument to Microsoft.Office.Interop.Word.Document.

static DocX g_document;
....
....
function DoSomething()
{
    g_document = DocX.Load(@"C:\Users\RetailWrite.docx");
    Microsoft.Office.Interop.Word.Application wordApp = new  Microsoft.Office.Interop.Word.Application();
    Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Add(g_document); // Here i m getting error
}

Then i want to retype caste the Microsoft.Office.Interop.Word back to DocX document. How do i do it?

Newton Sheikh
  • 1,376
  • 2
  • 19
  • 42
  • 1
    Google a bit before posting a question - Here is a solution http://stackoverflow.com/questions/5588995/c-sharp-word-interop-saving-docx-with-word-2003-compatibility-pack – dutzu Feb 27 '13 at 08:42
  • Na this wont work. I am using DocX.dll library to load the document and then i want to covert the loaded document into Interop.Word.Document – Newton Sheikh Feb 27 '13 at 08:44
  • If you work with `.docx` it's supposed to be a word 2007 on the computer, no? If no, dont use `.docx`. If you generate it automatically, there's a WordML dialect supported by Word 2003. It's not so different than 2007's WordML, but suddenly there are no good tools for generating it, so you'll need to dig into WordML markup. – RoadBump Feb 27 '13 at 10:31
  • Thanks RoadBump. WordML is seriously terrible. So i went for third party dlls instead. Earlier i used OpenXML but now i switched to DocX.dll to manipulate images on the .docx document. – Newton Sheikh Feb 27 '13 at 11:20
  • There's always the dirty way, save Docx document to file and open it with word. – RoadBump Mar 03 '13 at 05:03
  • Not sure but which DLL u have added ? version 11.0 or version 12.0 ? 12.0 should be the proper version. – Sangram Nandkhile Apr 15 '13 at 13:38

0 Answers0