A family of Microsoft word processing software products for creating web, email, and print documents.
Hello rudy dickens, welcome to Microsoft Q&A Forum.
The easiest way depends on how many files you need to convert.
If you only have a few files:
Open a .txt file directly in Word 2019 by right-click the file and choose Open with > Word. After it opens in Word, go to File > Save As and select Word Document (.docx).
This is quick and works well for small numbers of files.
If you have a lot of files:
You can automate the process with a VBA macro in Word. Here’s an example:
- Open Word and press Alt + F11 to open the VBA editor.
- Go to Insert > Module and paste this code:
Sub ConvertTxtToDocx()
Dim strFolder As String
Dim strFile As String
Dim wdDoc As Document
' Change this to your folder path
strFolder = "path"
strFile = Dir(strFolder & "*.txt")
While strFile <> ""
Set wdDoc = Documents.Open(FileName:=strFolder & strFile)
wdDoc.SaveAs2 FileName:=strFolder & Replace(strFile, ".txt", ".docx"), FileFormat:=wdFormatXMLDocument
wdDoc.Close
strFile = Dir
Wend
MsgBox "Conversion complete!"
End Sub
``
- Replace
pathwith the folder path where your text files are stored. For example: C:\Users\YourUserName\Desktop\TxtFiles - Run the macro (press F5 in the VBA editor).
This will convert all .txt files in that folder to .docx.
I hope this helps! Let me know if you have any further questions.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.