Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a number of folders with a number of documents in each folder. I would like to gather all the documents in each folder into one document. For example, in one folder there are 30 documents and I would like to make 1 document out of all of those 30.

    I know I can use the Insert/File. That would be OK if I only had one folder with 30 documents, but there are too many folders and it would take me forever.

    Can anybody tell me if there is something else I could do? Any help is greatly appreciated.

    You guys have helped me so much in the past. You guys are AWESOME!

    Thanks.

  2. #2
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='vgarrim' post='771943' date='23-Apr-2009 08:22']I have a number of folders with a number of documents in each folder. I would like to gather all the documents in each folder into one document. For example, in one folder there are 30 documents and I would like to make 1 document out of all of those 30.[/quote]

    Can you place all of the folders exclusively within one master folder?
    Do you care in what order the documents are placed in the composite file?
    Do you have any naming convention in mind for the composite file?
    Regards
    Don

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Here is some sample VBA code:

    Code:
    Sub MergeDemo()
      Dim strFolder As String
      Application.ScreenUpdating = False
      With Application.FileDialog(msoFileDialogFolderPicker)
    	If .Show = True Then
    	  strFolder = .SelectedItems(1)
    	  MergeDocuments (strFolder)
    	End If
      End With
      Application.ScreenUpdating = True
    End Sub
     
    Sub MergeDocuments(ByVal strFolder As String)
      Dim strFile As String
      Dim docIn As Document
      Dim docOut As Document
      Dim rng As Range
      Set docOut = Documents.Add
      If Not Right(strFolder, 1) = "\" Then
    	strFolder = strFolder & "\"
      End If
      strFile = Dir(strFolder & "*.doc")
      Do While Not strFile = ""
    	Set rng = docOut.Content
    	rng.Collapse Direction:=wdCollapseEnd
    	rng.InsertFile FileName:=strFolder & strFile
    	strFile = Dir
    	Set rng = docOut.Content
    	rng.Collapse Direction:=wdCollapseEnd
    	rng.InsertBreak Type:=wdSectionBreakNextPage
      Loop
    End Sub
    This could be expanded to loop through a series of folders, depending on the answers to the questions from Don Wells.

  4. #4
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='wdwells' post='771966' date='23-Apr-2009 14:47']Can you place all of the folders exclusively within one master folder?
    Do you care in what order the documents are placed in the composite file?
    Do you have any naming convention in mind for the composite file?[/quote]
    I am sorry I have not responded earlier. Thank you again guys for responding.

    Can you place all of the folders exclusively within one master folder?
    No. I need the folders to stay separate. What I need is to place all the documents in a particular folder into one document.

    Do you care in what order the documents are placed in the composite file?
    Yes. The documents need to be from document 1, 2, 3, to the end in order.

    Do you have any naming convention in mind for the composite file?
    No. I did not think about that. For what I have in mind it probably can be called Booklet.

    Again thank you.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If the folders are in varying locations, the macro from my previous reply should help.

    If you can produce a list of folders to be processed, it would be possible to adapt the macro to go through the list.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •