0

So I have a folder with a bunch of docx files and I want to turn them into PDFs. I could use the following method in a loop

$Word=NEW-OBJECT –COMOBJECT WORD.APPLICATION
$Doc=$Word.Documents.Open('"C:\[path]\word.docx"')
$Name=($Doc.Fullname).replace(“docx”,”pdf”)
$Doc.saveas([ref] $Name, [ref] 17)
$Doc.close()
$word.quit() 

But there are over 100 word files, and so it would take a while. I installed BullZip to test if it worked better but I don't know the code in order to use it in powershell. If anyone can provide it along with an explanation on how it works, I would appreciate it. Thanks

  • Have a look [here](https://www.bullzip.com/kb/pdf-command/) – Theo Jun 08 '21 at 13:53
  • "so it would take a while" - keep in mind, you only need to open Word (`$Word=NEW-OBJECT ...`) _once_ - repeating lines 2 through 5 for each document will likely be MUCH FASTER – Mathias R. Jessen Jun 08 '21 at 14:30
  • @MathiasR.Jessen, good point, another point to test. But I forgot where I found it, but apparently doing this often in a loop could make word crash. But I guess I could add sleeps using counters. – Milan Patel Jun 08 '21 at 14:39

0 Answers0