Skip to content

Commit ba50acf

Browse files
authored
Word to PDF converter
This scripts for Power Shell convert *.doc or *.docx documents to PDF in the same directory
1 parent 58c5427 commit ba50acf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pdfWordBatch.ps1

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<#
2+
# This script convert *.doc or *.docx files to PDF in batch mode
3+
# in case of failure you must run Power Shell as Administrator and put the follow command
4+
# PS > Set-ExecutionPolicy Unrestricted (press enter)
5+
# Will ask if you confirm your decision. you say Yes
6+
#
7+
# This script work on any place on your PC you only must define the work path in $Files
8+
# variable this folder must contain the word documents.
9+
#
10+
# Tested in: Windows 8 and Windows 8.1 with Office 360 installed
11+
#>
12+
13+
14+
$Files=Get-ChildItem 'C:\doc2pdf'
15+
16+
$Word = New-Object -ComObject Word.Application
17+
18+
Foreach ($File in $Files) {
19+
$Doc = $Word.Documents.Open($File.FullName)
20+
$Name=($Doc.FullName).replace('docx', 'pdf')
21+
$Doc.SaveAs($Name, 17)
22+
$Doc.Close()
23+
}
24+
<# optional line if fails try comment and run again #>
25+
$word.Quit()

0 commit comments

Comments
 (0)