Last active
July 24, 2020 23:37
-
-
Save ap-Codkelden/72b7823a45c8336ea98d4ca97923d9df to your computer and use it in GitHub Desktop.
RTF to TXT
This file contains hidden or 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
' converts all *.rtf in the current directory to *.txt | |
' WdCompatibilityMode enumeration(Word) 07.06.2019 | |
' Name Value Description | |
' wdCurrent 65535 Compatibility mode equivalent to the latest version of Word. | |
' wdWord2003 11 Word is put into a mode that is most compatible with Word 2003. Features new to Word are disabled in this mode. | |
' wdWord2007 12 Word is put into a mode that is most compatible with Word 2007. Features new to Word are disabled in this mode. | |
' wdWord2010 14 Word is put into a mode that is most compatible with Word 2010. Features new to Word are disabled in this mode. | |
' wdWord2013 15 Default. All Word features are enabled. | |
' Omit WdCompatibilityMode parameter when convert to TXT | |
Sub LoopDirectory() | |
Dim vDirectory As String | |
Dim oDoc As Document | |
vDirectory = "d:\reag\" | |
vFile = Dir(vDirectory & "*.docx") | |
Do While vFile <> "" | |
Set oDoc = Documents.Open(FileName:=vDirectory & vFile, _ | |
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _ | |
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ | |
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _ | |
wdOpenFormatAuto, XMLTransform:="", Encoding:=65001) | |
ActiveDocument.SaveAs2 FileName:=vDirectory & oDoc.Name & ".txt", _ | |
FileFormat:=wdFormatText, LockComments:=False, _ | |
Password:="", AddToRecentFiles:=True, WritePassword:="", _ | |
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _ | |
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False, _ | |
CompatibilityMode:=wdCurrent | |
oDoc.Close SaveChanges:=False | |
vFile = Dir | |
Loop | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment