Importing multiple rtf files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have over 100 rtf files, each about 25 pages in length. Is there a way to
import all 100 files into a single Word document, without having to import
each individually? I thought about developing a macro, but don't know how to
specify the files or fodler name.

Thanks.
 
Try this:

Dim MyPath As String
Dim MyFile As String
Dim Source As Document, Target As Document

With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With
If Len(MyPath) = 0 Then Exit Sub
If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
MyFile = Dir$(MyPath & "*.rtf")
Set Target = Documents.Add
While MyName <> ""
Set Source = Documents.Open(MyPath & myFile)
Target.Range.InsertAfter Source.Range
Source.Close wdDoNotSaveChanges
MyName = Dir
Wend


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top