Thread: [Solved] Insert multiple files
View Single Post
 
Old 12-27-2013, 02:58 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,381
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub InsertFiles()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String
strFolder = "C:\2\"
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "*.txt", vbNormal)
With Selection
  While strFile <> ""
    .InsertAfter strFile & vbCr
    .InsertFile FileName:=strFolder & strFile, ConfirmConversions:=False, Link:=False
    .InsertAfter vbCr & vbCr
    .Collapse wdCollapseEnd
    strFile = Dir()
  Wend
End With
Application.ScreenUpdating = True
End Sub
Note how minimal are the changes to the 'InsertFiles' sub from the code I originally posted.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote