Can you merge 2 Word documents together (not mail merge)

Discussion in 'Microsoft Word Document Management' started by Kurby, Dec 30, 2008.

  1. Kurby

    Kurby Guest

    I have 2 word documents both have a lot of photos and drawn lines and both
    would be a pain to copy and paste into another one so i'm wondering if i can
    merge one in the other or insert one into the other like you can with
    pictures or clip art.

    Thanks
     
    Kurby, Dec 30, 2008
    #1
    1. Advertisements

  2. Kurby

    Jay Freedman Guest

    On Mon, 29 Dec 2008 17:27:00 -0800, Kurby <>
    wrote:

    >I have 2 word documents both have a lot of photos and drawn lines and both
    >would be a pain to copy and paste into another one so i'm wondering if i can
    >merge one in the other or insert one into the other like you can with
    >pictures or clip art.
    >
    >Thanks


    For Word 2003 or earlier: With the cursor at the end of one document, click
    Insert > File and choose the second document from the dialog.

    For Word 2007: With the cursor at the end of one document, click the Insert tab
    of the ribbon, click the down arrow on the Object button, choose Text From File,
    and choose the second document from the dialog.

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP FAQ: http://word.mvps.org
    Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
     
    Jay Freedman, Dec 30, 2008
    #2
    1. Advertisements

  3. Kurby

    stipo

    Joined:
    Jul 28, 2012
    Messages:
    1
    Likes Received:
    0
    Here's a VB script which will merge many

    documents into one word doc, in filename

    alphabetic order. TO use: put the code below

    into a text file with suffix".vbs", and

    create a folder called "docs" in the same

    place where the .vbs script is. Place all the

    docs you wnt to merge into the docs folder,

    then drag it onto the .vbs file. The output

    will be created in "docs_CONCATENATED.doc".
    =========================================

    'DOCmerge - merges several Word documents (.DOC files) together
    'Author: George Birbilis () / Zoomicon (www.zoomicon.com)
    'Version: 20080325
    'On Error Resume Next
    const ONLY_DOC = false 'set to true to allow concatenation only of .DOC files (not .TXT etc.)
    const MSG_SYNTAX = "Drop a folder with Word (.DOC) documents onto this icon to produce a Word file with the concatenation of these documents"
    const MSG_FINISHED = "" '"Finished"
    const TXT_SUFFIX = "_CONCATENATED.doc"
    const wdPasteDefault = 0
    const wdPageBreak = 7
    '----------------------------------------
    dim word, fs, folderpath, outdocname, folder, outdoc
    '----------------------------------------
    '----------------------------------------
    Sub ShowList( ByRef arrListName, ByVal strPrefix )
    ' Custom subroutine displaying the contents of an ArrayList on a
    ' single line, and the capacity and size on a separate second line.
    ' Arguments used are:
    ' arrListName: the name of the ArrayList to be displayed
    ' strPrefix: a short description to be displayed before the
    ' actual content of the ArrayList

    Dim intLen, strItem, strList

    ' specify the maximum length of the descriptive text
    intLen = 20

    ' save the ArrayList content to a string
    For Each strItem in arrListName
    strList = strList & " " & strItem
    Next
    ' trim or pad the description to its maximum length, append the ArrayList content string, and display it
    WScript.Echo Left( strPrefix & Space( intLen ), intLen ) & ": " & strList
    ' display the ArrayList's current size and capacity
    WScript.Echo Left( "Count/Capacity" & Space( intLen ), intLen ) & ": " & arrListName.Count & "/" & arrListName.Capacity
    End Sub
    '-------------------------------------------------------
    Sub ParseCommandLine
    Dim args
    Set args = wscript.arguments
    if args.count = 0 then
    msgbox MSG_SYNTAX
    wscript.quit
    end if
    folderpath = args.item(0)
    outdocname = folderpath + TXT_SUFFIX
    End Sub
    '----------------------------------------
    Sub StartServers
    '-- Start Word
    Set word = CreateObject("Word.Application")
    'word.Visible = true
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set folder = fs.GetFolder(folderpath)
    End Sub
    '----------------------------------------
    Sub DeleteOldOutput
    If fs.FileExists(outdocname) Then
    fs.DeleteFile(outdocname)
    End If
    End Sub

    Sub ProcessFile(filename, insertBreak)
    Dim doc
    Set doc = word.Documents.Open(filename)
    word.Selection.WholeStory
    word.Selection.Copy
    outdoc.Activate
    if insertBreak then word.Selection.InsertBreak wdPageBreak

    'word.Selection.PasteAndFormat wdPasteDefault
    word.Selection.Paste 'use this one so that it works for Word2000 too
    doc.Close
    Set doc = Nothing
    End Sub

    Sub Process
    DeleteOldOutput
    Dim f, first
    Dim Item
    Dim outputLines
    first = true
    Set outputLines = CreateObject("System.Collections.ArrayList")
    For Each f in folder.Files
    if (ucase(right(f.path,4) ) = ".DOC" ) then
    outputLines.Add f.name
    'MsgBox f
    end if
    next
    outputLines.Sort
    ShowList outputLines, "output files"

    For Each Item in outputLines
    Dim fso, fileItem, filenm
    Set fso = CreateObject("Scripting.FileSystemObject")
    filenm = folderpath + "\" + Item

    'MsgBox filenm 'uncomment this if you want to see the files as they are processed

    Set fileItem = fso.GetFile(filenm)
    if (not ONLY_DOC) or (ucase(right(fileItem.path,4)) = ".DOC") then
    if first then
    Set outdoc = word.Documents.Add
    outdoc.SaveAs outdocname
    ProcessFile fileItem.path, false
    first = False
    else
    ProcessFile fileItem.path, true
    end if
    end if
    Next
    If Not first Then 'if at least one file was processed
    outdoc.Save
    outdoc.Close
    End If
    End Sub
    '----------------------------------------
    Sub Cleanup
    Set outdoc = Nothing
    word.Quit
    Set word = Nothing
    Set folder = Nothing
    Set fs = Nothing
    if MSG_FINISHED<>"" then MsgBox(MSG_FINISHED)
    End Sub
    '----------------------------------------
    ParseCommandLine
    StartServers
    Process
    Cleanup
     
    stipo, Jul 28, 2012
    #3
  4. Kurby

    roberts515

    Joined:
    Aug 24, 2012
    Messages:
    1
    Likes Received:
    0
    I love this script Stipo. How might we run it via command line?

    I intend to use it in a task sequence. During the application install phase, each application that was selected to be installed will drop its manual follow up procedures in this folder. During the cleanup phase I need these docs merged... but I need it to be interaction free.

    How might I modify your script to do this, either by passing it the folder name or better yet hard coding the value for the folder name?

    Again, great script and thank you for any help you are willing to offer!
     
    roberts515, Aug 24, 2012
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike

    Word XP, Mail Merge, Hyperlinks and Forms Together

    Mike, Nov 16, 2003, in forum: Microsoft Word Document Management
    Replies:
    1
    Views:
    318
    Doug Robbins - Word MVP
    Nov 16, 2003
  2. Guest

    Blank documents open together with opening of existing documents

    Guest, Jul 1, 2005, in forum: Microsoft Word Document Management
    Replies:
    1
    Views:
    277
    Cindy M -WordMVP-
    Jul 1, 2005
  3. gmax2006
    Replies:
    1
    Views:
    1,557
    Guest
    Mar 28, 2007
  4. Nat

    Merge two documents together to create one doc with collapsible li

    Nat, Aug 15, 2008, in forum: Microsoft Word Document Management
    Replies:
    1
    Views:
    186
    Robert M. Franz (RMF)
    Aug 21, 2008
  5. Gene

    how do i link 2 words together so they always wrap together

    Gene, Sep 11, 2009, in forum: Microsoft Word Document Management
    Replies:
    1
    Views:
    284
    Tony Jollans
    Sep 11, 2009
Loading...

Share This Page