MS Word configurator

Post Reply
essexmate
Member
Posts: 30
Joined: Tue Sep 05, 2017 4:41 pm

MS Word configurator

Post 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.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: MS Word configurator

Post by gabrielp »

You could give openoffice headless a try. Another option would be to use a cloud service like cloudconvert.com
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: MS Word configurator

Post by sander »

With a Powershell script via Execute Command you probably won’t even notice it’s already done :)
Arthur
Member
Posts: 113
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: MS Word configurator

Post 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 ??
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: MS Word configurator

Post 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
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: MS Word configurator

Post by Padawan »

If you have them, I would be really interested in numbers showing how much faster this is compared to the configurator :)
Arthur
Member
Posts: 113
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: MS Word configurator

Post 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.
Post Reply