Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining word documents

Status
Not open for further replies.

AFI247365

Programmer
Jul 12, 2001
13
US
I have many .rtf's that I wish to combine into one big file. Is there a way to join all of these files?
 
here's one way using a Rich Text Box control

Code:
Option Explicit

Private Sub Form_Load()
  Dim sPath As String
  Dim sFile As String
  Dim sOutput As String
  
  RichTextBox1.Text = ""
  
  sPath = "D:\Justin's Folder\RTFs\"
  sFile = Dir(sPath & "*.rtf")
  sOutput = "D:\Justin's Folder\Combined.rtf"
  
  Show
  Do While sFile <> &quot;&quot;
    InsertFile sPath & sFile
    sFile = Dir
    RichTextBox1.Refresh
  Loop
  
  RichTextBox1.SaveFile sOutput
End Sub

Private Sub InsertFile(ByVal sFile As String)
  Dim nFile As Integer
  Dim sCont As String
  
  sCont = Space$(FileLen(sFile))
  nFile = FreeFile
  Open sFile For Binary As nFile
  Get nFile, , sCont
  Close nFile
  
  RichTextBox1.SelRTF = sCont
End Sub

Private Sub Form_Resize()
  RichTextBox1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top