Results 1 to 13 of 13

Thread: Combining multiple word documents into one

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    InsertFile works for me from an Excel file

    Option Explicit
    Sub Combine()
    'This code requires a referece to the Word object model
         'and windows scripting runtime
    Dim Appword As New Word.Application
        Dim fso, fldr, f
    Set Appword = CreateObject("Word.Application")
        Appword.Documents.Add
    Set fso = New FileSystemObject
        Set fldr = fso.GetFolder("C:\AAA")
        For Each f In fldr.Files
       If Right(f.Name, 4) = ".doc" Then
          Appword.Selection.InsertFile Filename:="C:\AAA\" & f.Name
       End If
        Next f
    Appword.Visible = True
    End Sub
    Last edited by Aussiebear; 04-12-2023 at 06:08 PM. Reason: Adjusted the code tags
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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