Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to convert word docs to PDF 1

Status
Not open for further replies.

cj7owner

MIS
Jan 26, 2006
38
CA
I have a PDF995 Printer installed and usually print the Word doc to the printer which saves as a PDF file.

Can someone provide a script that converts a batch of word docs in a folder to the printer (PDF) files?

 
This should work for you:

Code:
'This script will open all word docs in a directory and print them.
'Must specify directory name WITHOUT path
'Default printer must be set to desired printer
'djtech2k sportsfan@teamarsenal.net

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService. _
    ExecQuery("Select * from CIM_DataFile where Path = '\\docs_folder_name\\'")

For Each objFile in colFiles
	Set objWord = CreateObject("Word.Application")
    Set objDoc = objWord.Documents.Open(objFile.Name)
	objDoc.PrintOut()
    objWord.Quit
Next

Remember to set your PDF995 printer as your default BEFORE you start. Also remember to set the directory name to where the files are. This will open and print each automatically.
 
works great, the only thing is I would like it to run without any user intervention, it currently prompts me to save the PDF document when printed. Can that be added to it to save automatically?

thanks so much

Corry
 
and if the document already exists to overwrite, thanks.
 
I do not think that can be done with vbscript. Thats how the pdf995 software works. Unless there is a command-line way to call their software and tell it how to name the file, I do not know how it could be done.
 
got past it, used the PDFEDIt utility to accomplish it. Thanks
 
one more thing if you have time,

Could you provide the code for determining if it is an excel file as well. I tried it with excel and it just gave me junk. The folder will have a mix of excel and word files and all need to be converted.

thanks for your help

Corry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top