Hi mizankabir,
the following macro allows you to simply select a folder and have Word import the contents of
all txt files in that folder.
Code:
Sub Import_Text()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document, txtFile As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.txt", vbNormal)
Set wdDoc = ActiveDocument
While strFile <> ""
Set txtFile = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False, ConfirmConversions:=False)
wdDoc.Range.InsertAfter txtFile.Range.Text & vbCr
txtFile.Close SaveChanges:=True
strFile = Dir()
Wend
Set txtFile = Nothing: Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function