Hi script wizzards...,
i cobbled this together from info on the web but i dont know hardly anything about scripting - i'm a COBOL propgrammer! Works with word 2003/2007 (has been for some time) but not in word 2010. The background printing commands fail (e.g. objWord.Options.PrintBackground = False). It works without them but then word is not invisible. I'd like one script that works in all versions. Help!
'*** This script converts all of the rtf files in the '*** current folder to pdf files for use with adBooker '*** email invoicing. Microsoft Word and PDFCreator '*** must already be installed on the same computer.
'*** Developed by Linden Rowland, October 2009. '*** Generated automatically by adBooker v2.08.
Set objFSO = CreateObject("Scripting.FileSystemObject")
If False = objFSO.FileExists("RGL7089_email_merge_data.csv") Then MSGBOX "Merge files missing! If you are " + _ "running from a zip folder, you need " + _ "to extract all of the files first " + _ "and run from there. Click OK to exit. " Wscript.Quit End If
If objFSO.FolderExists("C:EMAIL_INVOICE_MERGE") Then MSGBOX "About to empty folder, C:EMAIL_INVOICE_MERGE. If you need any of the files, move them now BEFORE clicking OK." objFSO.DeleteFile("C:EMAIL_INVOICE_MERGE*.*") Else MSGBOX "Ooops! - you may have tried to run this program by mistake - it can only be run on the computer that will send the email invoices. Click OK to exit." Wscript.Quit End If
strFolderName = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) Set objFolder = objFSO.GetFolder(strFolderName)
Set objWord = CreateObject("Word.Application") objWord.Visible = False strActivePrinter = objWord.ActivePrinter objWord.ActivePrinter = "PDFCreator"
For Each objFile In objFolder.Files IF right(objFile,4) = ".rtf" THEN strFileName = strFolderName & objFile.Name Set objDoc = objWord.Documents.Open(strFileName) objWord.Options.PrintBackground = False objDoc.PrintOut() objWord.Options.PrintBackground = True objDoc.Close() End if Next
objWord.ActivePrinter = strActivePrinter objWord.Quit
Const OverwriteExisting = True objFSO.CopyFile "*_email_merge_data.csv" , "C:EMAIL_INVOICE_MERGE", OverwriteExisting
MSGBOX "Before you run Pegasus, please check the PDFs in folder, C:EMAIL_INVOICE_MERGE. There may be a short delay before all of the PDFs appear."
November 4, 2010 6:59 PM
November 15, 2010 8:02 PM