If found this VBSCRIPT on the internet and somehow figured out a way to alter the registry to set the PDF Output Directory. It works on my computer but I can't get visible=false to work. I set PDF output to same directory as WORD docs but you can change that.
[pre]
filename FT66F001 'path to word docs';
data _null_;
length path script filevar command $256;
path = pathname('FT66F001');
script = catx('\',pathname('WORK'),'DOC2PDF.vbs');
filevar = script;
/* write the script */
file dummy1 filevar=filevar;
put path=:$quote256.;
infile cards eof=eof;
do while(1);
input;
put _infile_;
end;
eof:
/* close the script file by opening another, not used */
filevar = catx('\',pathname('WORK'),'DUMMY.vbs');
file dummy1 filevar=filevar;
/* look at the script, not necessary but may be useful */
infile dummy2 filevar=script end=eof;
file log ls=256;
do _n_ = 1 by 1 until(eof);
input;
put _n_ z3. +1 _infile_;
end;
/* call the script */
command = catx(' ','cscript //nologo',quote(strip(script)));
infile dummy3 pipe filevar=command end=eof length=l;
do until(eof);
input;
putlog _infile_;
end;
stop;
cards;
Set objShell = WScript.CreateObject("WScript.Shell")
hkey = "HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\7.0\AdobePDFOutputFolder"
hkey0 = hkey & "\" '(Default)
default = objShell.RegRead(hkey0) 'Save default
WScript.Echo "Default=" & default
hkey5 = hkey & "\5"
objshell.RegWrite hkey5,path,"REG_SZ" 'PDF Path
objshell.RegWrite hkey0,5,"REG_DWORD" 'Set as default
WScript.Echo objshell.RegRead(hkey0) & " " & objshell.RegRead(hkey5)
Set WordObj = WScript.CreateObject("Word.Application")
WordObj.Visible = False
wordObj.DisplayAlerts = False
Set FS = CreateObject("Scripting.FileSystemObject")
Set FD = FS.GetFolder(Path) 'collection of files in path
For Each File In FD.Files
If Right(File.Name,3) = "doc" then
WordObj.Documents.Open(path & "\" & file.Name)
WordObj.ActivePrinter = "Adobe PDF"
WordObj.Options.UpdateFieldsAtPrint = False
WordObj.Options.PrintBackground = True
WordObj.Options.PrintReverse = False
WordObj.PrintOut
WordObj.Documents.Close
If Err.Number <> 0 then
'MsgBox("error" & Err.Number & vbCR & filename & vbCR & Err.Description)
WScript.Echo "ERROR: " & err.number & " " & filename & " " & Err.Description
end if
End if
Next
WordObj.Quit
objshell.RegWrite hkey0,default,"REG_DWORD"
objshell.RegDelete(hkey5)
;;;;
run;
[/pre]
... View more