![]() ![]() WPS Office is an all-in-one office suite to view and edit multiple types of files, including PDF, Word, Excel, PowerPoint, and Forms. If ((Test-Path $Name) -And (Get-Item $Name).★WPS Office is an office suite for PDF, Word, Excel, and PPT files. $Word = New-Object -ComObject Word.Application So, here's the resulting code: $Files=Get-ChildItem -path '.\path\to\docs' -recurse -include "*.doc*" If you don't want to skip already generated PDFs, you can delete that if statement.Įxcuse me if my code doesn't look good, I don't generally use Windows and this was a one-off hack. So, when skipping already generated pdfs, I make sure they are at least 3kb in size. So, my hack to get it to proceed was to kill and restart word every 100 docs (arbitrarily chosen number).Īdditionally, when it did crash occasionally, there would be resulting malformed pdfs, each of which were generally 1-2 kb in size. As it turns out, doing this repeatedly eventually leads to Word crashing, presumably due to memory issues (the error was some COMException that I didn't know how to parse). The above answers all fell short for me, as I was doing a batch job converting around 70,000 word documents this way. ![]() FullyQualifiedErrorId : DotNetMethodExceptionĪlso - how would I need to change it to also convert doc (not docX) files, as well as use the local files (files in same location as the script location)? CategoryInfo : NotSpecified: (:), MethodInvocationException \docx2pdf.ps1Įxception calling "SaveAs" with "16" argument(s): "Command failed" # Save this File as a PDF in Word 2010/2013Īnd I keep on getting this error and can't figure out why: PS C:\docx2pdf>. # open a Word document, filename from the directory $Word=NEW-OBJECT –COMOBJECT WORD.APPLICATION $Files=GET-CHILDITEM "C:\docx2pdf\*.DOCX" # Acquire a list of DOCX files in a folder I am trying to use PowerShell to do a batch conversion of Word Docx to PDF - using a script found on this site: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |