0

I am using the following code which works fine in Visual Studio 2010 integrated Web Server but when deployed on IIS I get error on the ** line:

        Word.Application oWord = new Word.Application();
        Word.Document oWordDoc; //= new Word.Document();
        object breakPage = Word.WdBreakType.wdPageBreak;

        oWord.Visible = false;
        oWord.Options.set_DefaultFilePath(Microsoft.Office.Interop.Word.WdDefaultFilePath.wdUserTemplatesPath, Server.MapPath(TemplatesFolder)); //@"D:\Presentationalism\Presentationalism\Presentations\Templates");

        Object oTemplatePath = Server.MapPath(TemplatesFolder + templates[ddTemplates.SelectedIndex]);
        **oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);**

        oWordDoc.Activate(); 

following is the error:

Word was unable to read this document.  It may be corrupt.
Try one or more of the following:
* Open and Repair the file.
* Open the file with the Text Recovery converter.

how do I fix it?

Ali
  • 1,648
  • 2
  • 26
  • 48
  • Is your IIS on the the same machine? Is word 2010 on the IIS server? Are you sure the document path is correct on the IIS server? – Andrew Apr 13 '12 at 13:11
  • I am not sure what you are trying to do, but I would suggest that if you want to manipulate word documents on the fly and you are using IIS you should rather consider using openXml – Andrew Apr 13 '12 at 13:14
  • @Andrew IIS is on the same machine, It seems to work fine with the integrated webserver of visual studio 2010 but not on IIS what's wrong with it? – Ali Apr 13 '12 at 13:16

0 Answers0