Created
April 28, 2018 17:52
-
-
Save rsxdalv/69023c0e38f127a96b759f5453509e82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extended from https://superuser.com/a/1187598 | |
$Word = New-Object -ComObject Word.Application | |
$Files = Get-ChildItem ".\**\*.docx" | |
ForEach ($File In $Files) { | |
$Document = $Word.Documents.Open($File.FullName) | |
$Name = ($Document.FullName).Replace("docx", "txt") | |
$def = [Type]::Missing | |
# 17 - pdf | |
# 2 - text | |
# 7 - unicode text | |
$Document.SaveAs( | |
#ref Object FileName, | |
[ref] $Name, | |
#ref Object FileFormat, | |
[ref] 7, | |
#ref Object LockComments, | |
$def, | |
#ref Object Password, | |
$def, | |
#ref Object AddToRecentFiles, | |
$def, | |
#ref Object WritePassword, | |
$def, | |
#ref Object ReadOnlyRecommended, | |
$def, | |
#ref Object EmbedTrueTypeFonts, | |
$def, | |
#ref Object SaveNativePictureFormat, | |
$def, | |
#ref Object SaveFormsData, | |
$def, | |
#ref Object SaveAsAOCELetter, | |
$def, | |
#ref Object Encoding, | |
65001 | |
#ref Object InsertLineBreaks, | |
#ref Object AllowSubstitutions, | |
#ref Object LineEnding, | |
#ref Object AddBiDiMarks | |
) | |
$Document.Close() | |
} | |
$Word.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment