title: How can I programmatically open Powerpoint without seeing the window?
body: <p>I have this script, made by another user</p>
  
  <p>It opens the input file, converts it to a .pdf and saves it as the output file.</p>
  
  <p>However, PowerPoint also opens, and I see the actual window load up.</p>
  
  <p>This process is going to be running on a server, so I figure that loading up the GUI every time a user wants to convert something is going to be unnecessarily resource intensive.</p>
  
  <p>Is there any way to programmatically open PowerPoint without the GUI popping up?</p>
  
  <hr>
  
  <p>I've tried replacing</p>
  
  <p><code>objPPT.Visible = True</code> with </p>
  
  <p><code>objPPT.Visible = False</code></p>
  
  <p>But that throws an error telling me that it cannot be that way.</p>
  
  <p>I've also tried replacing </p>
  
  <p><code>objPPT.Presentations.Open inputFile</code>with</p>
  
  <p><code>objPPT.Presentations.Open inputFile,,,msoFalse</code></p>
  
  <p>But that gives me an error saying:</p>
  
  <blockquote>
    <p>Microsoft PowerPoint 2013: Application.ActivePresentation : Invalid
    request.  There is no active presentation.</p>
  </blockquote>
  
  <p>The error is triggered from the  <code>Set objPresentation = objPPT.ActivePresentation</code> line.</p>
  
  <hr>
  
  <p>From doing some research about the subject, I found that some people have success by
  using the <a href="http://msdn.microsoft.com/en-us/library/office/ff746171.aspx" rel="nofollow">Open method</a></p>
  
  <p>The fourth parameter is <code>WithWindow</code>. Theoretically, this should open the presentation without a window if set to false.</p>
  
  <p>But whatever I do to it doesn't seem to work.</p>
  
  <p><code>WithWindow:= false</code> gives me a syntax error</p>
  
  <hr>
  
  <pre><code>' Courtesy BillP3rd of superuser.com
  
  Option Explicit
  
  Sub WriteLine ( strLine )
      WScript.Stdout.WriteLine strLine
  End Sub
  
  ' http://msdn.microsoft.com/en-us/library/office/aa432714(v=office.12).aspx
  Const msoFalse = 0   ' False.
  Const msoTrue = -1   ' True.
  
  ' http://msdn.microsoft.com/en-us/library/office/bb265636(v=office.12).aspx
  Const ppFixedFormatIntentScreen = 1 ' Intent is to view exported file on screen.
  Const ppFixedFormatIntentPrint = 2  ' Intent is to print exported file.
  
  ' http://msdn.microsoft.com/en-us/library/office/ff746754.aspx
  Const ppFixedFormatTypeXPS = 1  ' XPS format
  Const ppFixedFormatTypePDF = 2  ' PDF format
  
  ' http://msdn.microsoft.com/en-us/library/office/ff744564.aspx
  Const ppPrintHandoutVerticalFirst = 1   ' Slides are ordered vertically, with the first slide in the upper-left corner and the second slide below it.
  Const ppPrintHandoutHorizontalFirst = 2 ' Slides are ordered horizontally, with the first slide in the upper-left corner and the second slide to the right of it.
  
  ' http://msdn.microsoft.com/en-us/library/office/ff744185.aspx
  Const ppPrintOutputSlides = 1               ' Slides
  Const ppPrintOutputTwoSlideHandouts = 2     ' Two Slide Handouts
  Const ppPrintOutputThreeSlideHandouts = 3   ' Three Slide Handouts
  Const ppPrintOutputSixSlideHandouts = 4     ' Six Slide Handouts
  Const ppPrintOutputNotesPages = 5           ' Notes Pages
  Const ppPrintOutputOutline = 6              ' Outline
  Const ppPrintOutputBuildSlides = 7          ' Build Slides
  Const ppPrintOutputFourSlideHandouts = 8    ' Four Slide Handouts
  Const ppPrintOutputNineSlideHandouts = 9    ' Nine Slide Handouts
  Const ppPrintOutputOneSlideHandouts = 10    ' Single Slide Handouts
  
  ' http://msdn.microsoft.com/en-us/library/office/ff745585.aspx
  Const ppPrintAll = 1            ' Print all slides in the presentation.
  Const ppPrintSelection = 2      ' Print a selection of slides.
  Const ppPrintCurrent = 3        ' Print the current slide from the presentation.
  Const ppPrintSlideRange = 4     ' Print a range of slides.
  Const ppPrintNamedSlideShow = 5 ' Print a named slideshow.
  
  ' http://msdn.microsoft.com/en-us/library/office/ff744228.aspx
  Const ppShowAll = 1             ' Show all.
  Const ppShowNamedSlideShow = 3  ' Show named slideshow.
  Const ppShowSlideRange = 2      ' Show slide range.
  
  '
  ' This is the actual script
  '
  
  Dim inputFile
  Dim outputFile
  Dim objPPT
  Dim objPresentation
  Dim objPrintOptions
  Dim objFso
  
  If WScript.Arguments.Count &lt;&gt; 2 Then
      WriteLine "You need to specify input and output files."
      WScript.Quit
  End If
  
  inputFile = WScript.Arguments(0)
  outputFile = WScript.Arguments(1)
  
  Set objFso = CreateObject("Scripting.FileSystemObject")
  
  If Not objFso.FileExists( inputFile ) Then
      WriteLine "Unable to find your input file " &amp; inputFile
      WScript.Quit
  End If
  
  If objFso.FileExists( outputFile ) Then
      'WriteLine "Your output file (' &amp; outputFile &amp; ') already exists!"
      'WScript.Quit
  End If
  
  WriteLine "Input File:  " &amp; inputFile
  WriteLine "Output File: " &amp; outputFile
  
  Set objPPT = CreateObject( "PowerPoint.Application" )
  
  objPPT.Visible = True
  
  objPPT.Presentations.Open inputFile
  Set objPresentation = objPPT.ActivePresentation
  Set objPrintOptions = objPresentation.PrintOptions
  
  objPrintOptions.Ranges.Add 1,objPresentation.Slides.Count
  objPrintOptions.RangeType = ppShowAll
  
  ' Reference for this at http://msdn.microsoft.com/en-us/library/office/ff746080.aspx
  objPresentation.ExportAsFixedFormat outputFile, ppFixedFormatTypePDF, ppFixedFormatIntentScreen, msoTrue, ppPrintHandoutHorizontalFirst, ppPrintOutputSlides, msoFalse, objPrintOptions.Ranges(1), ppPrintAll, "Slideshow Name", False, False, False, False, False
  
  objPresentation.Close
  ObjPPT.Quit
  </code></pre>
  
  <hr>
  
  <p>I found out about OpenXML, and I'm looking into that.</p>