File Format & Compatibility

Batch Convert DOC and RTF Files to TXT in Microsoft Word

Maira MehtabMaira Mehtab Nov 25, 2026 868 views

Question details

Convert a large collection of DOC and RTF documents to plain-text files without manually opening and saving each one.

Batch Convert DOC and RTF Files to TXT in Microsoft Word
Product
Microsoft Word
Device & OS
not provided
Scenario
The user has a folder of Word DOC and RTF files and wants to convert them in a batch.
Observed behavior
Each source document should produce a TXT file without requiring an individual Save As operation.
Before you start

Place the DOC and RTF files to convert in one folder and use desktop Microsoft Word on Windows for the macro below. The macro processes only that folder, not its subfolders; check that the documents can be opened without passwords or other prompts.

Solution 1Recommended

Run a Word VBA macro to convert a folder to TXT

Use this method to convert DOC and RTF files in one folder while keeping the original files unchanged.

The macro creates a TXT_Converted subfolder and skips an output file if a TXT file with the same name already exists. If a DOC and an RTF file share the same base name, only the first one processed is converted.

Plain text does not preserve Word formatting, images, or other non-text content. The text encoding used by wdFormatText may not preserve every character, so check a sample output before converting the full collection.

1
Open the VBA editor

In desktop Word on Windows, press Alt+F11, then choose Insert > Module.

2
Paste the macro

Paste this code into the module: Sub BatchConvertToText() Dim picker As Object, fso As Object, folder As Object, file As Object Dim sourcePath As String, outputPath As String, ext As String Dim converted As Long, skipped As Long, failed As Long Set picker = Application.FileDialog(4) picker.Title = "Select the folder containing DOC and RTF files" If picker.Show <> -1 Then Exit Sub sourcePath = picker.SelectedItems(1) Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(sourcePath) outputPath = fso.BuildPath(sourcePath, "TXT_Converted") If Not fso.FolderExists(outputPath) Then fso.CreateFolder outputPath For Each file In folder.Files ext = LCase$(fso.GetExtensionName(file.Name)) If ext = "doc" Or ext = "rtf" Then ConvertOneToText file.Path, fso.BuildPath(outputPath, fso.GetBaseName(file.Name) & ".txt"), converted, skipped, failed End If Next file MsgBox "Converted: " & converted & vbCrLf & "Skipped: " & skipped & vbCrLf & "Failed: " & failed, vbInformation End Sub Private Sub ConvertOneToText(ByVal sourceFile As String, ByVal targetFile As String, ByRef converted As Long, ByRef skipped As Long, ByRef failed As Long) Dim doc As Document Dim fso As Object On Error GoTo FailedConversion Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(targetFile) Then skipped = skipped + 1 Exit Sub End If Set doc = Documents.Open(FileName:=sourceFile, ReadOnly:=True, AddToRecentFiles:=False, Visible:=False) doc.SaveAs2 FileName:=targetFile, FileFormat:=wdFormatText, AddToRecentFiles:=False doc.Close SaveChanges:=False converted = converted + 1 Exit Sub FailedConversion: failed = failed + 1 On Error Resume Next If Not doc Is Nothing Then doc.Close SaveChanges:=False End Sub

3
Run the conversion

Place the cursor inside BatchConvertToText and press F5. Select the source folder in the folder picker and wait for the conversion count.

4
Check the results

Open the TXT_Converted subfolder and inspect several TXT files. Review any skipped or failed files individually in Word.

Run a Word VBA macro to convert a folder to TXT
Macro permissions: Word must allow the macro to run. Follow your organization's macro security policy rather than enabling untrusted macros.
Free Microsoft Office alternative

Open and edit Word documents with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing documents. Its format compatibility helps you move existing files over, although it does not fix or replace the Word-specific batch macro above.

Open and edit documents in a familiar word-processing interfaceWork with Microsoft Word DOC and DOCX formatsReview document content before exporting it to plain textMove existing Office files into a lightweight office suite
QA img-9

Frequently Asked Questions

Will the macro convert files in subfolders?

No. Select a folder in the folder picker, and the macro converts only DOC and RTF files directly inside it.

What happens if two documents have the same name?

If a DOC and an RTF file have the same base name, they would produce the same TXT name. The macro converts the first one it processes and skips the other rather than overwriting the output.

Where are the converted TXT files saved?

Open the source folder and look for its TXT_Converted subfolder. The original DOC and RTF files remain in the source folder.

Will TXT files retain formatting and images?

No. Plain text does not retain Word formatting or images. Open a sample TXT file after conversion to check its content and characters.