File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
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 ()
You can’t perform that action at this time.
0 commit comments