|
#1
|
||||
|
||||
Try this version
Code:
Sub Import_Text() Dim strFolder As String, strFile As String, wdDoc As Document Application.ScreenUpdating = False strFolder = GetFolder If strFolder = "" Then Exit Sub strFile = Dir(strFolder & "\*.rtf", vbNormal) ChangeFileOpenDirectory strFolder Set wdDoc = ActiveDocument While strFile <> "" wdDoc.Range.InsertAfter vbCr & strFile & vbCr wdDoc.Range.Paragraphs.Last.Range.InsertFile FileName:=strFolder & "\" & strFile, ConfirmConversions:=False, Link:=False, Attachment:=False strFile = Dir() Wend Set wdDoc = Nothing Application.ScreenUpdating = True End Sub Function GetFolder() As String Dim oFolder As Object 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
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia Last edited by Guessed; 11-27-2023 at 07:44 PM. |
#2
|
|||
|
|||
This does pull all the content in BUT it does not put the filenames in the resulting document like the previous version did.
Quote:
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Merging Word documents | kp4bnx | Word VBA | 4 | 03-10-2021 02:49 PM |
Batch merging of Word documents | Harry Gateaux | Word VBA | 6 | 11-19-2020 09:58 AM |
Updating links while merging Word documents | ndw | Word VBA | 1 | 11-10-2017 01:07 PM |
Merging two tables in WORD with VBA | ffinley | Word VBA | 3 | 03-14-2017 07:43 PM |
Merging different documents in one big document keeping the chapters, figure numbers and tables | village | Word | 8 | 06-06-2016 04:16 AM |