title: How to achieve late binding in c# for Microsoft.office.interop.word?
body: <p>I want to achieve late binding for the following lines of code which are using early binding. How can I achieve it in C#?</p>
  
  <p>When I removed Microsoft.office.interop.word reference, I am getting some errors, which are mentioned in the comments in following code.
  Folloowing is the code I am using to convert a word document to pdf.</p>
  
  <pre><code>    Type wordType = Type.GetTypeFromProgID("Word.Application");
  
          dynamic Word = Activator.CreateInstance(wordType);
  
  
          object oMissing = System.Reflection.Missing.Value;
  
  
          DirectoryInfo dirInfo = new DirectoryInfo(@"\\server\folder");
          FileInfo wordFile = new FileInfo(fileName);
  
          Word.Visible = false;
          Word.ScreenUpdating = false;
  
          Object filename = (Object)wordFile.FullName;
  
  
          var doc = Word.Documents.Open(ref filename);
          doc.Activate();
  
          object outputFileName = wordFile.FullName.Replace(".doc", ".pdf");
  
      /*Getting an error in WdSaveFormat */ 
          object fileFormat = WdSaveFormat.wdFormatPDF;
  
  
  
          doc.SaveAs(ref outputFileName, ref fileFormat);
  
  
  
          /*Getting an error in WdSaveOptions */       
          object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
  
      /*Getting an error in _Document*/ 
          ((_Document)doc).Close(ref saveChanges);
          doc = null;
  
  
          Word.Quit();
  
  
          MessageBox.Show("Successfully converted");
  </code></pre>