Genius123
asked on
Print PDF using VB Script
Hello,
I use a customized Outlook form that runs VB Script. I have a command button that opens up a Word template and prints it to a PDF file. What happens though is when printing, the save PDF dialog box comes up. I don't want that. I want it to save it as a PDF automatically without the dialog box coming up. Let's just say C:\test.pdf. Here's the code that I currently use.
Thank you,
Joel
I use a customized Outlook form that runs VB Script. I have a command button that opens up a Word template and prints it to a PDF file. What happens though is when printing, the save PDF dialog box comes up. I don't want that. I want it to save it as a PDF automatically without the dialog box coming up. Let's just say C:\test.pdf. Here's the code that I currently use.
Sub CommandButtonShipLabelUSPS_Click()
On Error Resume Next
Dim strCurrentPrinter' As String
Set objDoc2 = GetWordDocLabel("\\TGPS13VM1\drawing$\Jobs\Task_Templates\Ship-Ship Label USPS.dot")
Call FillFieldsShipLabel(objDoc2)
objDoc2.Application.Options.PrintBackground = False
objDoc2.Application.DisplayAlerts = False
if Item.UserProperties("PrintHold") = True then
Set objDoc2 = Nothing
Set strCurrentPrinter = Nothing
Set objWord2 = Nothing
Exit Sub
end if
strCurrentPrinter = objDoc2.Application.ActivePrinter ' store the current active printer
objDoc2.Application.ActivePrinter = "Adobe PDF" ' change to another printer
objDoc2.PrintOut ' print the active sheet
Call RestoreActivePrinter
objDoc2.Application.DisplayAlerts = True
objDoc2.Application.Options.PrintBackground = True
objDoc2.Close wdDoNotSaveChanges
objWord2.Quit wdDoNotSaveChanges
Set objDoc2 = Nothing
Set strCurrentPrinter = Nothing
Set objWord2 = Nothing
End Sub
Thank you,
Joel
ASKER
Thank you. Do you know how I would define the variable OutputFilename? I just declared it like "Dim OutputFilename", but it doesn't work. It still brings up the save dialog box.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, this worked.
Open in new window