Server 2009

Automate Printing with PowerPoint

Example code is for an older version of Server, newer code is available.
' Copyright (c) 2020 ActivePDF, Inc.
' ActivePDF Server 2009
' Example generated 01/17/20 

Dim FSO, strPath, intStartPrinting, intWait

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Path and filename of output
oSVR.OutputDirectory = strPath
oSVR.NewDocumentName = "Output.pdf"

' Start the print job
intStartPrinting = oSVR.StartPrinting()
If intStartPrinting <> 0 Then
  ErrorHandler "StartPrinting", intStartPrinting
End If

' Automate PowerPoint to print a document to activePDF Server
Set objPPT = CreateObject("PowerPoint.Application")
Set objDoc = objPPT.Presentations.Open(strPath & "PPT.ppt", -1, 0, 0)
Set objOptions = objDoc.PrintOptions
objOptions.ActivePrinter = oSVR.NewPrinterName
objOptions.PrintInBackground = 0
objDoc.PrintOut 1, 9999, "", 1, 0
objDoc.Saved = 1
objDoc.Close
objPPT.Quit
Set objOptions = Nothing
Set objDoc = Nothing
Set objPPT = Nothing

' Wait(seconds) for job to complete
intWait = oSVR.Wait(30)
If intWait <> 0 Then
  ErrorHandler "Wait", intWait
End If

' Release Object
Set oSVR = Nothing

' Process Complete
Wscript.Echo("Done!")

' Error Handling
Sub ErrorHandler(method, outputCode)
  Wscript.Echo("Error in " & method & ": " & outputCode)
End Sub

Copyright © 2020 ActivePDF, Inc