Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm doing this to automate the conversion of our doc and docx documents to pdf:</p> <pre><code>private bool ConvertDocument(string file) { object missing = System.Reflection.Missing.Value; OW.Application word = null; OW.Document doc = null; try { word = new OW.Application(); word.Visible = false; word.ScreenUpdating = false; Object filename = (Object)file; doc = word.Documents.Open(ref filename, 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, ref missing, ref missing); doc.Activate(); if (Path.GetExtension(file) == ".docx") file = file.Replace(".docx", ".pdf"); else file = file.Replace(".doc", ".pdf"); object fileFormat = OW.WdSaveFormat.wdFormatPDF; doc.ExportAsFixedFormat(file, OW.WdExportFormat.wdExportFormatPDF, false, OW.WdExportOptimizeFor.wdExportOptimizeForPrint, OW.WdExportRange.wdExportAllDocument, 1, 1, OW.WdExportItem.wdExportDocumentContent, true, true, OW.WdExportCreateBookmarks.wdExportCreateNoBookmarks, true, true, false, ref missing); } catch(Exception ex) { return false; } finally { if (doc != null) { object saveChanges = OW.WdSaveOptions.wdDoNotSaveChanges; ((OW._Document)doc).Close(ref saveChanges, ref missing, ref missing); doc = null; } if (word != null) { ((OW._Application)word).Quit(ref missing, ref missing, ref missing); word = null; } } return true; } </code></pre> <p>where OW is an alias for Microsoft.Office.Interop.Word.</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. 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.
 

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