title: Passing a namespace into a function
body: <p>I've got a function which takes a word document and saves it in html format. I'd like to use the same function to work with any document type. I've tried using generics (I'm assumming the different doc APIs are the same) which fails due to the reason Jon Skeet pointed out. Is there another way?</p>
  
  <pre><code>using Word = Microsoft.Office.Interop.Word;
  using Excel = Microsoft.Office.Interop.Excel;
  
  //Works ok
  private void convertDocToHtm( string filename )
  {
  ... snip
  
       var app = new Word.Application();
       var doc = new Word.Document();
       doc = app.Documents.Open(ref fileName, ref missing, ref trueValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
  
  ... snip    
  }
  
  //fails dismally (to compile) because 'T' is a 'type parameter', which is not valid in the given context - i.e Word is a namespace not a class
  private void convertDocToHtm2&lt;T&gt;( string filename )
  {
  ... snip
  
       var app = new T.Application();
       var doc = new T.Document();
       doc = app.Documents.Open(ref fileName, ref missing, ref trueValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
  
  ... snip
  }
  
  //calling examples
  convertDocToHtm( filename );
  convertDocToHtm2&lt;Word&gt;( filename );
  convertDocToHtm2&lt;Excel&gt;( filename );
  </code></pre>