View Single Post
 
Old 11-27-2023, 05:27 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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.
Reply With Quote