i need to develope a script that allows me to print an attached pdf file using ole automation. I know it is very similar to the one below that prints attached MS Word documents. What is the CreateObject parameter to pass? How do I close it after it prints, so that the user does not have to close it.
Dim app As Variant
Dim docToPrint As Variant
Dim PrintBackground As Integer
On Error 208 Goto err208
Set app = createobject("Word.application")
Set docToPrint = app.documents.open(fname)
’ Turn off background printing to avoid error message cf. Microsoft Technote #Q170393
PrintBackground = app.Options.PrintBackground()
If PrintBackground = True Then app.Options.PrintBackground = False
Call docToPrint.PrintOut()
app.Options.PrintBackground = PrintBackground 'Restore PrintBackground option
Call app.Quit(0)
Set app = Nothing
Exit Sub