Re: AppleScript to Combine Several .doc Files

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Paul Berkowitz (berkowit_at_spoof_silcom.com)
Date: 09/16/04


Date: Wed, 15 Sep 2004 20:35:15 -0700

On 9/15/04 2:51 PM, in article BD6E31A6.EDBC%selowitch@gwi.net, "Sam
Elowitch" <selowitch@gwi.net> wrote:

> Is there an AppleScript that sequentially combines a folder full of Word
> docs into a single document?

1. Copy and paste the following script into Script Editor
(/Applications/AppleScript/).
2. Save it (named "Combine Word Docs") as an Application, anywhere
convenient. You can drag it into the dock if you wish.
3, Re-name - or make copies of your docs and rename the copies - so that
they appear in list or column view in the order in which you wish to combine
them (i.e. alphabetical order).
4. Command-click or shift-click all the documents you wish to combine to
select them all.
5. Drag them onto the applet you saved ("Combine Word Docs").
6. The combined doc will be open in Word. Name it and save it in the usual
manner.

on open theFiles
    
    tell application "Microsoft Word" to set comboDoc to make new document
    
    repeat with i from 1 to (count theFiles)
        set theFile to item i of theFiles
        set filePath to theFile as Unicode text
        tell application "Finder"
            set {creaType, fileType} to {creator type, file type} of theFile
            set ext to name extension of theFile
            set fileName to name of theFile
        end tell
        if (creaType is "MSWD" and {fileType} is in {"BINA", "W8BN", "s8BN",
"W6BN", "s6BN", "RTF "}) or ext = "doc" then
            tell application "Microsoft Word"
                set comboRange to text object of comboDoc
                set collapsedRange to collapse range comboRange direction
collapse end
                insert file file name filePath at collapsedRange
            end tell
        end if
    end repeat
    tell application "Microsoft Word" to activate
end open

-- 
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>
Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.
PLEASE always state which version of Microsoft Office you are using -
**2004**, X  or 2001. It's often impossible to answer your questions
otherwise.


Relevant Pages

  • Re: I need a Redirect Applescript???
    ... > set theMessages to current messages ... > repeat with aMessage in theMessages ... > You will need top paste this script into Script Editor and run it from there ­ ... > select some messages in the front window of entourage before you start. ...
    (microsoft.public.mac.office.entourage)
  • Re: I need a Redirect Applescript???
    ... > set theMessages to current messages ... > repeat with aMessage in theMessages ... > You will need top paste this script into Script Editor and run it from there ­ ... > select some messages in the front window of entourage before you start. ...
    (microsoft.public.mac.office.entourage)
  • Re: AppleScript to Combine Several .doc Files
    ... AppleScript to Combine Several .doc FilesMy God.. ... > docs into a single document? ... Drag them onto the applet you saved. ... Entourage FAQ Page: ...
    (microsoft.public.mac.office.word)
  • Re: Split recipients script: character set problem
    ... > character encoding. ... If I set a specific setting, i.e. Greek ISO in the ... Near the top of the script, in Script Editor, you'll see a section: ... Entourage FAQ Page: ...
    (microsoft.public.mac.office.entourage)
  • Re: how to delete single attachment in multiple attachment message
    ... This script will work on any OS with any script editor: ... set theMsg to item 1 of ... repeat with theAttachment in ...
    (microsoft.public.mac.office.entourage)