Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>private Microsoft.Office.Interop.Word.ApplicationClass MSdoc; //Use for the parameter whose type are not known or say Missing object Unknown = Type.Missing; private void word2PDF(object Source, object Target) { //Creating the instance of Word Application if (MSdoc == null)MSdoc = new Microsoft.Office.Interop.Word.ApplicationClass(); try { MSdoc.Visible = false; MSdoc.Documents.Open(ref Source, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown); MSdoc.Application.Visible = false; MSdoc.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize; object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF; MSdoc.ActiveDocument.SaveAs(ref Target, ref format, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown); } catch (Exception e) { MessageBox.Show(e.Message); } finally { if (MSdoc != null) { MSdoc.Documents.Close(ref Unknown, ref Unknown, ref Unknown); //WordDoc.Application.Quit(ref Unknown, ref Unknown, ref Unknown); } // for closing the application WordDoc.Quit(ref Unknown, ref Unknown, ref Unknown); } } </code></pre> <p>Prerequisites:</p> <ul> <li>MS word2007 with (Primary Interoperability assembly will be installed by default).</li> <li>plugin <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4d951911-3e7e-4ae6-b059-a2e79ed87041&amp;displaylang=en" rel="nofollow">SaveAsPDFandXPS</a> (free from MS Site)</li> </ul> <p><strong>Make sure you have reference to Word.12. It will automatically add Microsoft.Office.interop.word to your reference. Follow these for other office application. (Note: you should have installed VS 2005 Tools for Office 2nd Ed. Runtime (VSTO 2005 SE) (x86)</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload