Page 1 of 1

MS Word configurator

Posted: Wed Jul 18, 2018 12:33 pm
by essexmate
Does anyone know if the MS Word configurator supports multi-thread? I have over 1000 Word files to convert to PDF but it is taking forever in Switch.

Re: MS Word configurator

Posted: Mon Jul 23, 2018 7:12 pm
by gabrielp
You could give openoffice headless a try. Another option would be to use a cloud service like cloudconvert.com

Re: MS Word configurator

Posted: Mon Jul 23, 2018 7:24 pm
by sander
With a Powershell script via Execute Command you probably won’t even notice it’s already done :)

Re: MS Word configurator

Posted: Mon Jul 30, 2018 10:56 am
by Arthur
sander wrote: Mon Jul 23, 2018 7:24 pm With a Powershell script via Execute Command you probably won’t even notice it’s already done :)
Sander - have you got it implemented that way ?? Any working script you could share ??

Re: MS Word configurator

Posted: Mon Jul 30, 2018 12:33 pm
by sander
Arthur wrote: Mon Jul 30, 2018 10:56 am Sander - have you got it implemented that way ?? Any working script you could share ??
Nope I'm using a lot of xlsx to csv and reversed but not doc. However I created this one for you.

This is something we don't need to reinvent, I got most of this script @ https://stackoverflow.com/questions/165 ... ocx-to-pdf.

Edit: tested with a job folder as input!

Code: Select all

#
# Script:  		docToPdf, Save Word files as pdf
#
# Last edit: 	30-07-2018 by Sander, Drukkerij Wihabo
#
# Sources: 		https://stackoverflow.com/questions/16534292/basic-powershell-batch-convert-word-docx-to-pdf
#

param(
[string]$1 = "",     # Switch %1: the absolute path of the input file/job folder
[string]$2 = "",     # Switch %2: the absolute path of the output file/job folder (which does not yet exist) including filename and extension
[string]$3 = ""      # Switch %3: the absolute path of a folder (which does exist) in which output or temp files may be placed
)


<# test 
$3 = "d:\tempOut"
$1 = "d:\temp"
$log = "d:\temp\log.log"
Add-Content -path $log -Value $1
Add-Content -path $log -Value $2
Add-Content -path $log -Value $3
#>

$word = New-Object -ComObject Word.Application


Get-ChildItem -Path $1 -Filter *.doc? | ForEach-Object {

    $doc = $word.Documents.Open($_.FullName)

    $outPdf = "$3\$($_.BaseName).pdf"
    # Add-Content -path $log -Value $outPdf
    $doc.SaveAs([ref] $outPdf, [ref] 17)

    $doc.Close()
}


# Quit Word The Scripting Guy way, just to be sure we can remove all temp files.
$word.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($word)
Remove-Variable Word

EXIT 0
Image
Command: C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
Argument: -NoLogo -WindowStyle hidden -executionpolicy bypass -file D:\Scripts\PowerShell\docToPdf.ps1 -1 "%1" -2 "%2" -3 "%3"

Hope this helps :)

Sander

Re: MS Word configurator

Posted: Mon Jul 30, 2018 4:58 pm
by Padawan
If you have them, I would be really interested in numbers showing how much faster this is compared to the configurator :)

Re: MS Word configurator

Posted: Mon Jul 30, 2018 6:14 pm
by Arthur
Hi;
Thank you very much for this. I need to test it and see how it works, as it is not so much about processing a ready folder with hundreds or thousands of Word Docs, as about individual ones, which cue up in the standard Word configurator, when processed on "per file" basis. So if I have lets say (just for you to envisage the situation) 20-30 word docs cued in front of the configurator, while Switch is doing some other things or processing other files, it takes significant amount time with the configurator to convert it to PDF.
So I am looking for an alternative, which goes quicker via the CLI, on a 'per file' basis.
But I'll see if this is going to do the trick.