Advertisement
Guest User

BulkWord2PDF

a guest
Jun 11th, 2013
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # Acquire a list of DOCX files in a folder
  2.  
  3. $File=”C:\Foofolder\foofile.docx"
  4. $Files=GET-CHILDITEM ‘C:\FooFolder\*.DOCX’
  5. $Word=NEW-OBJECT –COMOBJECT WORD.APPLICATION
  6.  
  7.  
  8. Foreach ($File in $Files) {
  9.  
  10. # open a Word document, filename from the directory
  11.  
  12. $Doc=$Word.Documents.Open($File.fullname)
  13.  
  14.  
  15.  
  16. # Swap out DOCX with PDF in the Filename
  17.  
  18. $Name=($Doc.Fullname).replace(“docx”,”pdf”)
  19.  
  20.  
  21.  
  22. # Save this File as a PDF in Word 2010/2013
  23.  
  24. $Doc.saveas([ref] $Name, [ref] 17)
  25.  
  26. $Doc.close()
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement