Jump to content

Please read the Forum Rules before posting.

Photo

Combining many html, rtf, doc, txt, or even word perfect files


  • Please log in to reply
5 replies to this topic

#1 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 07 January 2012 - 10:22 PM

This Microsoft Word macro will combine all files in a folder. Doesn't matter if you have 5 files or 500. It works on HTML files, RTF, DOC, DOCX, plain text files, and even wordperfect and open office files. I'm using this to combine dozens of RTF files together at once without manually opening each one and copying it.


Sub MergeDocs()

Dim rng As Range

Dim MainDoc As Document

Dim strFile As String

'EDIT THIS TO INCLUDE YOUR PATH AND FOLDER NAME
Const strFolder = "F:\lange\OT\gen\footnote\"

Set MainDoc = Documents.Add

'EDIT THE FILE EXTENSION IF NECESSARY.
'If you are combining HTML files, change rtf extension to .htm or .html
strFile = Dir$(strFolder & "*.rtf")

Do Until strFile = ""

Set rng = MainDoc.Range

rng.Collapse wdCollapseEnd

rng.InsertFile strFolder & strFile

strFile = Dir$()

Loop

End Sub


#2 BaptizedBeliever

BaptizedBeliever

    Christian

  • Members (T)
  • PipPipPipPipPip
  • 924 posts
Offline

Posted 07 January 2012 - 10:49 PM

What about pdf files? Another question is this: will it place the files in a specific order? Or just however it wants?

Brad

#3 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 07 January 2012 - 10:52 PM

It combines alphanumerically/alphabetically. It won't combine PDF's.

#4 BaptizedBeliever

BaptizedBeliever

    Christian

  • Members (T)
  • PipPipPipPipPip
  • 924 posts
Offline

Posted 07 January 2012 - 11:09 PM

ok. so, it'll combine all the html files together...as an html file? Or as a rtf/docx file?

Brad

#5 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 07 January 2012 - 11:34 PM

It combines all the files into a live Word document that's not anything until you save it. You save it as...a PDF, a docx, txt, rtf, html, all the save as options.

#6 BaptizedBeliever

BaptizedBeliever

    Christian

  • Members (T)
  • PipPipPipPipPip
  • 924 posts
Offline

Posted 08 January 2012 - 03:43 PM

Thanks for posting this. I just used it and it helped save at least 15-20 minutes of copy/paste and formatting with each file.

Brad




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users




Similar Topics



Latest Blogs