Re: Scripting MS Word "Insert Subdocument"
Re: Scripting MS Word "Insert Subdocument"
- Subject: Re: Scripting MS Word "Insert Subdocument"
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 19 Oct 2004 12:40:56 -0700
Title: Re: Scripting MS Word "Insert Subdocument"
On 10/19/04 12:18 PM, I wrote:
For 2004, here's a sample script provided by someone at MacBU that shows the entire
process of making a document, turning it into a master document, re-aligning (demoting)
headings as needed, and making subdocuments both from text and from a file. The bit
inserting a subdocument is just the last two lines of the script - that may be all you
need.
And here's a better version. The gyrations to get named references to the documents created in the earlier version aren’t necessary. They were apparently copied from a script written against a pre-release incarnation of the dictionary, in which the ‘make new document’ event returned indexed references.
The ‘make new document’ event in the released Word dictionary returns named references, so this isn’t necessary.
-------------------------------------------------------------------
tell application "Microsoft Word"
activate
close every document saving no
-- create two documents
set masterDoc to make new document
set subDoc to make new document
-- set view type to Master View
set view type of view of active window of masterDoc to master view
-- create master document content
set content of text object of masterDoc to ¬
"Master document" & return & ¬
"Subdocument 1" & return & ¬
"Subdocument 2" & return
set para2 to paragraph 2 of masterDoc
set para3 to paragraph 3 of masterDoc
outline demote para2
outline demote para3
-- create subdocument content
set content of text object of subDoc to "Subdocument 3" & return
-- get Documents folder
set docFolder to (path to documents folder) as Unicode text
-- ########## CREATE SUBDOCUMENTS FROM RANGES ##########
set subdoc1 to make new subdocument at text object of para3
set subdoc2 to make new subdocument at text object of para2
-- save master document
save as masterDoc file name docFolder & "Master.doc"
-- name changed - reset reference variables
set masterDoc to document "Master.doc"
set subdoc1 to subdocument 1 of masterDoc
set subdoc2 to subdocument 2 of masterDoc
-- save subdocument file
save as subDoc file name docFolder & "subDoc.doc"
-- name changed - reset reference variable
set subDoc to document "subDoc.doc"
-- ########## CREATE SUBDOCUMENT FROM FILE ##########
-- Note: The new subdocument replaces the selection
select last character of masterDoc
set subdoc3 to make new subdocument in masterDoc with properties ¬
{path:docFolder & "subDoc.doc"}
end tell
----------------------------------------
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden