title: Microsoft.Office.Interop.Word.Document.saveas get Command failed on server
body: <p>I try to convert convert .doc to .pdf using Microsoft.Office.Interop.Word
  as per the below code which is working on my PC but when I upload it to the server I get </p>
  
  <blockquote>
    <p>"Command failed"</p>
  </blockquote>
  
  <p>at <code>doc1.SaveAs</code> on the server; on my machine it's working</p>
  
  <pre><code>//***********************************************************
  Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
  
          // C# doesn't have optional arguments so we'll need a dummy value
          object oMissing = System.Reflection.Missing.Value;
  
          // Get list of Word files in specified directory
          //DirectoryInfo dirInfo = new DirectoryInfo(@"\\server\folder");
          FileInfo wordFile = new FileInfo(FromLocation);
  
          word.Visible = false;
          word.ScreenUpdating = false;
  
          // Cast as Object for word Open method
          Object filename = (Object)wordFile.FullName;
  
          // Use the dummy value as a placeholder for optional arguments
          Microsoft.Office.Interop.Word.Document doc1 = word.Documents.Open(ref filename, ref oMissing,
              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
              ref oMissing, ref oMissing, ref oMissing, ref oMissing);
          doc1.Activate();
  
          object outputFileName = wordFile.FullName.Replace(".doc", ".pdf");
          object fileFormat = WdSaveFormat.wdFormatPDF;
  
          // Save document into PDF Format
          doc1.SaveAs(ref outputFileName,
              ref fileFormat, ref oMissing, ref oMissing,
              ref oMissing, ref oMissing, ref oMissing, ref oMissing,
              ref oMissing, ref oMissing, ref oMissing, ref oMissing,
              ref oMissing, ref oMissing, ref oMissing, ref oMissing);
  
          // Close the Word document, but leave the Word application open.
          // doc has to be cast to type _Document so that it will find the
          // correct Close method.                
          object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
          ((_Document)doc1).Close(ref saveChanges, ref oMissing, ref oMissing);
          doc1 = null;
  
          // word has to be cast to type _Application so that it will find
          // the correct Quit method.
          ((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);
          word = null;
  
          return outputFileName.ToString();
  </code></pre>