Thread: [Solved] Insert multiple files
View Single Post
 
Old 12-26-2013, 07:04 PM
fumei fumei is offline Windows 7 64bit Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Myfault. Needed to get rid of strFolder, as it was not used. BTW: I suspect you are not using Option Explicit as you should have got an error with strFolder to start with.

Code:
Sub InsertFiles()
Application.ScreenUpdating = False
Dim strFile As String
strFile = Dir("C:\2\*.txt", vbNormal)
With Selection
While strFile <> ""
.InsertAfter strFile & vbCr
.InsertFile FileName:=strFile, ConfirmConversions:=False, Link:=False
.InsertAfter vbCr & vbCr
.Collapse wdCollapseEnd
strFile = Dir()
Wend
End With
Application.ScreenUpdating = True
End Sub
Reply With Quote