Word 2010 Macro 轉存純文字

Sub word_to_text()

' 將某個資料夾下的 *.docx 轉為純文字,UTF8 with BOM

' Ray Chou 2016/4/24

myInDir = "C:\temp\in\"

myOutDir = "C:\temp\out\"

Dim strFile As String

strFile = Dir(myInDir + "*.docx")

Do While strFile <> ""

Set myDoc = Documents.Open(myInDir & strFile)

myOutFile = myOutDir & myDoc.Name

myOutFile = Replace(myOutFile, ".docx", ".txt")

ActiveDocument.SaveAs2 FileName:=myOutFile, _

FileFormat:=wdFormatText, _

Encoding:=msoEncodingUTF8

myDoc.Close

strFile = Dir

Loop

End Sub