Copy files (old kind) from folders in sequence and paste into one word document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JakoLaubscher
    New Member
    • Dec 2014
    • 2

    Copy files (old kind) from folders in sequence and paste into one word document

    Hi Guys

    I found an old thread discussing almost something similar


    but im look for a way to open files in sequence in a folder and copy paste them into my word document.

    the related one i found opens the next file but i want to copy and paste them in my active document.

    Code:
    Sub B07LoadingCond()
    '
    
        Dim LC1 As Document
        Dim LC2 As Document
        Dim LC3 As Document
        Dim LC4 As Document
        Dim LC5 As Document
        Dim LC6 As Document
        Dim LC7 As Document
        Dim LC8 As Document
        Dim LC9 As Document
        Dim LC10 As Document
        Dim Chapter7 As Document
        Dim newdoc As Document
        
        Dim Path As String
        Dim Path1 As String
        Dim Path2 As String
        Dim Path3 As String
        Dim Path4 As String
        Dim Path5 As String
        Dim Path6 As String
        Dim Path7 As String
        Dim Path8 As String
        Dim Path9 As String
        Dim Path10 As String
        Dim Path11 As String
        
        Dim rng As Range
           
        Path = "y:\Chapter 7 - LCs"
        Path1 = Path & "\LC1.rtf"
        Path2 = Path & "\LC2.rtf"
        Path3 = Path & "\LC3.rtf"
        Path4 = Path & "\LC4.rtf"
        Path5 = Path & "\LC5.rtf"
        Path6 = Path & "\LC6.rtf"
        Path7 = Path & "\LC7.rtf"
        Path8 = Path & "\LC8.rtf"
        Path9 = Path & "\LC9.rtf"
        Path10 = Path & "\LC10.rtf"
        Path11 = Path & "\Chapter7.docx"
                
        Set newdoc = Documents.Add
        newdoc.SaveAs Path11
        
        Set LC1 = Documents.Open(Path1)
        Set LC2 = Documents.Open(Path2)
        Set LC3 = Documents.Open(Path3)
        Set LC4 = Documents.Open(Path4)
        Set LC5 = Documents.Open(Path5)
        Set LC6 = Documents.Open(Path6)
        Set LC7 = Documents.Open(Path7)
        Set LC8 = Documents.Open(Path8)
        Set LC9 = Documents.Open(Path9)
        Set LC10 = Documents.Open(Path10)
    
        Set Chapter7 = Documents.Open(Path11)
        
        LC1.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
    
        LC2.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
        
        LC3.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
        
        LC4.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
        
        LC5.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
        
        LC6.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
        
        LC7.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
        
        LC8.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
    
        LC9.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
           
        LC10.Content.Copy
        Set rng = Chapter7.Content
        rng.Collapse Direction:=wdCollapseEnd
        rng.Paste
            
        LC1.Close SaveChanges:=False
        LC2.Close SaveChanges:=False
        LC3.Close SaveChanges:=False
        LC4.Close SaveChanges:=False
        LC5.Close SaveChanges:=False
        LC6.Close SaveChanges:=False
        LC7.Close SaveChanges:=False
        LC8.Close SaveChanges:=False
        LC9.Close SaveChanges:=False
        LC10.Close SaveChanges:=False
        Chapter7.SaveAs Path11
        
      
    End Sub

    of course you can see there is another problem im pointing to a specific file name. That I dont want and only want to use a fill in form where the user selects the root folder and click run.

    any help on some of the above please?
    Last edited by Rabbit; Dec 25 '14, 09:28 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • JakoLaubscher
    New Member
    • Dec 2014
    • 2

    #2
    subject line shouldve read
    Copy files (all kind) from folders in sequence and paste into one word document

    all kind meaning some rtf files some jpg files etc

    there are 12 folders (or more)
    with 10files in each folder (or less/more)

    tnx guys

    Comment

    Working...