I have a Heading 1 at the start of what I would like to be the start of
each new doc.
Is there an easy way to do this please?
An Applescript (preferred) or VBA solution would be welcome.
Roger
Sorry, omitted to say: Mac OS 10.4.6 and Word 11.2
also
re length of docs - typically a 100 page document would produce nearly
100 separate new documents
Roger
Yes, there is. Look up "Master Documents" in the Help.
Basically, you need to
1) Save the file to a new name
2) Go into Master Document view
3) Select ALL
4) Hit Insert Subdocument
5) Hold down Shift and choose Save All from the File menu
Word will save each Heading 1 section as a new document, named after the
first string of text in the Heading 1.
Discard the Master Document and use only the subdocuments. If you attempt
editing in the Master Document view, you will get a short sharp lesson in
"How fast Master Documents corrupt".
Cheers
On 10/5/06 6:20 AM, in article
1hf39rd.12p1ncrovt72eN%r...@rmfsnewsXL.fsnet.co.uk.invalid, "Roger Morris"
<r...@rmfsnewsXL.fsnet.co.uk.invalid> wrote:
--
Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.
John McGhie <jo...@mcghie.name>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410
I couldn't get that to work.
Wasn't sure about the "hit insert subdocument" but Save All simply saved
back the whole doc.
Looked at Help - there is a procedure to Split Subdocument but it seems
only to work with one heading (one split) at a time.
I thought I could make it happen with applescript
open document
get/cut the range from the first H1 to just before the next H1 -- ??
create new document
paste into / save newly created doc
repeat above
At the moment I haven't been able to select/cut the range which includes
the first H1 down to immediately before the next H1 - it's not a
consistent number of paragraphs throughout the (big) document.
Roger
Roger
It can, but it would be easier if you had started a new section with each
Heading 1. Too late for that now?
In order to make new files, you have to tell us how you want to name them.
Suppose the original document is called "Document Blah.doc". Do you want the
separate docs to be called "Document Blah 1.doc", "Document Blah 2.doc",
etc. ? Or do you want the separate documents to have the names of the
Headings that begin them? Or what exactly? Presumably they should be saved
to the same folder as the long doc? There's always a possibility that a doc
of the same name already exists in that folder, necessitating a complicated
routine for re-naming them. IMO, it would be safer for the script to create
a new subfolder of the same name as the long doc (but without ".doc"
extension) or however you want (and the routine can check just _its_ name),
and make the separate docs within that.
--
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.
> On 5/9/06 1:03 PM, in article
> 1hf38uh.df4dxn19a38meN%r...@rmfsnewsXL.fsnet.co.uk.invalid, "Roger Morris"
> <r...@rmfsnewsXL.fsnet.co.uk.invalid> wrote:
>
> > I have several long Word documents (50 to 100 pages) that I would like
> > to split (save as) into many separate docs (files).
> >
> > I have a Heading 1 at the start of what I would like to be the start of
> > each new doc.
> >
> > Is there an easy way to do this please?
> >
> > An Applescript (preferred) or VBA solution would be welcome.
>
> It can, but it would be easier if you had started a new section with each
> Heading 1. Too late for that now?
I think so, these (big) Word docs are not new (unless a section break
could be inserted by a script?)
In fact they are various diaries and each Heading 1 styled text is a new
month. Each doc contains several years worth of data.
The text of the heading is consistent so can easily be changed and as it
contains both a month name and a 4 digit year number I intended to get
the new file names from there. There would be no duplicates.
I feel that I can handle the whole script with necessary repeats, new
doc creation etc except for the all important bit of selecting the one
month of data from the big document. So far, this is where I've failed.
This is the sequence (with para styles H1=Heading 1, N=Normal):
H1 "Diary for September 2001 (and a few other words)"
N "d1 ..." (arbitrary text)
N "d2 ..."
N "d3 ..." etc to month end (but not necessarily every day)
H1 "Diary for October 2001 (and a few other words)
My problem at present is finding out how to select and cut the portion:
"Diary for ..."
up to but not including the next "Diary for ..."
I supposed that cutting it to the clipboard would be best, I'm then only
ever searching for the first set of data.
Then all I have to do is create a new word doc, give it a name, paste
the text in and save it. I have done something like this before so
shouldn't have a problem (likewise the repeats and doc, sub folder
choosing/creating) - Does that sound like "famous last words"?
Mac OS 10.4.6 and Word 11.2
John McGhie suggested a way using Master Document processing but so far
I have not had any success with this either.
Roger
--
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.
> If I'm going to give you an example, it has to be something I can test. So
> please answer how you want to name the separate files, as I asked in my last
> post.
OK, Thank you.
A (big) document is named "RM diary.doc"
The data in it is in groups like this:
"Diary for September 2001 (+ other words)"
"some text for day 1"
"some text for day 2"
"some text for day 3" etc for most days of the month
"Diary for October 2001 (+ other words)"
"some text for day 1"
etc - could be 3 - 5 years of data (up to 60 files)
I would like the separate files named (**) :
2001 September
2001 October
etc
and to be in a new sub folder named "RM diaries" in the same folder as
"RM diary.doc"
( ** ideally 01 to 12 for month names instead of January to December to
preserve calendar ordering but this could be easily changed by renaming
afterwards)
Assume there are no duplicate names.
The headings (for file names) can be identified by being formatted in
style "Heading 1". No other lines use this style.
The words at the start of the heading lines "Diary for mmmm yyyy " are
consistent so could be edited by find & replace all. There are other
(non consistent) words in the heading lines
I hope there is enough information here and look forward to your example
which will be very welcome.
Thank you
Roger
Did you read up on Master Documents in the Help? I use this feature all the
time for web publishing :-)
Insert Subdocument is a button on the Master Document toolbar, which will
appear when you go into Master Document View, which you can do only from the
View menu.
H1 won't work. It must be "Heading 1" style... It can be any of the
"Heading..." series of styles, but it must be one of the built-in Word
heading styles. It should have told you in the help that this will work
only if the FIRST paragraph in your selection is the heading style level at
which you want to split the document. So if you want to split at the
Heading 3's, the first paragraph in your selection must be a Heading 3.
Ignore Split Subdocument, this is not what you want.
Cheers
On 11/5/06 2:50 AM, in article
1hf4u2a.uivz2s1et9bp8N%r...@rmfsnewsXL.fsnet.co.uk.invalid, "Roger Morris"
<r...@rmfsnewsXL.fsnet.co.uk.invalid> wrote:
--
Point of clarification if you will - I thought Insert Subdocument was for
inserting a separate existing file into a Master as a Sub.
It seems to me that what the OP wants to do would better be handled by the
Create Subdocument button, since the content is already in the Master &
needs to be output to individual files.
--
Regards |:>)
Bob Jones
[MVP] Office:Mac
"John McGhie [MVP - Word and Word Macintosh]" <jo...@mcghie.name> wrote in
message news:C0893DA8.3859F%jo...@mcghie.name...
You are utterly correct: The button is named "Create Subdocument" and I
cannot think why I chose the wrong one.
{Blush...} Senior moment, I think...
On 12/5/06 3:27 AM, in article #3nnLfRd...@TK2MSFTNGP02.phx.gbl,
"CyberTaz" <typegeneraltaz1ATcomcastdotnet> wrote:
> Hi John -
>
> Point of clarification if you will - I thought Insert Subdocument was for
> inserting a separate existing file into a Master as a Sub.
>
> It seems to me that what the OP wants to do would better be handled by the
> Create Subdocument button, since the content is already in the Master &
> needs to be output to individual files.
--
Please reply to the newsgroup to maintain the thread. Please do not email
Have you seen John's suggestion, with CyberTaz's correction, to do this via
Master Document/Create Subdocuments? It's really the easiest way.
I thought I'd try to automate that for you, replacing the Heading 1 lines'
text with the substitutions you wanted perhaps. Te best way to automate is
always to let the application (Word) do the main work. Since it can make
subdocuments in a folder all in one step, I simply wanted to automate that
step rather than trying to do complicated messy text parsing. But the
AppleScript command corresponding to "Create Subdocuments" (equivalent to
VBA's AddFromRange command) is _missing_ from AppleScript!
I'm going to report that as a bug - it needs to be supplied forthwith. In
the meantime, it could be done as a VBA macro, I guess. Or I could try the
complicated, messy text parsing, scripting a Find of Heading 1 paragraphs,
etc. But since it's really so easy just to do it in the UI, I'm really not
sure this is worth the effort, is it?
--
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.
> From: Roger Morris <r...@rmfsnewsXL.fsnet.co.uk.invalid>
> Newsgroups: microsoft.public.mac.office.word
> Date: Thu, 11 May 2006 09:31:04 +0100
> Subject: Re: Split doc to many files
>
I wasn't going to say anything! (except thank you both)
I thought perhaps your /deliberate mistake/ was to encourage me to study
the help :-)
Well, I did study the help and did discover "Create Subdocument" and
then the procedure you suggested worked well and fast.
I had to do some find&replace exercises to get the Heading 1 into a more
suitable form for a file name (Create Subdocs uses the whole para) but
that was not difficult.
Thank you
Roger
John McGhie [MVP - Word and Word Macintosh] <jo...@mcghie.name> wrote:
> Damn, I'm stupid!! I checked that TWICE and STILL wrote the wrong thing :-)
>
> You are utterly correct: The button is named "Create Subdocument" and I
> cannot think why I chose the wrong one.
>
> {Blush...} Senior moment, I think...
>
>
> On 12/5/06 3:27 AM, in article #3nnLfRd...@TK2MSFTNGP02.phx.gbl,
> "CyberTaz" <typegeneraltaz1ATcomcastdotnet> wrote:
>
> > Hi John -
> >
> > Point of clarification if you will - I thought Insert Subdocument was for
> > inserting a separate existing file into a Master as a Sub.
> >
> > It seems to me that what the OP wants to do would better be handled by the
> > Create Subdocument button, since the content is already in the Master &
> > needs to be output to individual files.
Roger
Thank you for your efforts - much appreciated. Let's hope the bg gets
corrected soon.
I did use John's suggestion and it did work albeit by using the whole
Heading 1 paragraph as the file name. That was easily smoothed.
I also continued with my efforts to use Applescript (complicated messy
text parsing) and eventually found out how to create, select and extend
ranges. ("Word 2004 AppleScript Reference" proved a great help in that
task)
The rest of the script was straightforward and that too now works
effectively, even if a lot slower than via Master Document/Create
Subdocuments.
I appreciate you point about letting the application do the main work.
The best solution is probably the Master Docs route but the Applescript
way has probably added more to my knowledge.
Thank you.
Roger
Paul Berkowitz <berkowit@spoof_silcom.com> wrote:
> Well, it's all a muddle.
>
> Have you seen John's suggestion, with CyberTaz's correction, to do this via
> Master Document/Create Subdocuments? It's really the easiest way.
>
> I thought I'd try to automate that for you, replacing the Heading 1 lines'
> text with the substitutions you wanted perhaps. Te best way to automate is
> always to let the application (Word) do the main work. Since it can make
> subdocuments in a folder all in one step, I simply wanted to automate that
> step rather than trying to do complicated messy text parsing. But the
> AppleScript command corresponding to "Create Subdocuments" (equivalent to
> VBA's AddFromRange command) is _missing_ from AppleScript!
>
> I'm going to report that as a bug - it needs to be supplied forthwith. In
> the meantime, it could be done as a VBA macro, I guess. Or I could try the
> complicated, messy text parsing, scripting a Find of Heading 1 paragraphs,
> etc. But since it's really so easy just to do it in the UI, I'm really not
> sure this is worth the effort, is it?
Roger
Regards |:>)
Bob Jones
[MVP] Office:Mac
On 5/12/06 7:32 AM, in article C08AAF75.38855%jo...@mcghie.name, "John McGhie
You do it in VBA the same way, John. Probably the "trick" is to remember that a Subdocument, unlike a Document, does not have Paragraphs: first you have to get the Range of the Subdoc, then get its Paragraphs, then their Ranges.
Your first guess would be the one. A subdocument "should" be a document
object and should contain paragraphs :-) If it doesn't that would be why
activedocument.subdocuments didn't work, and I didn't have time to fiddle
around to find out why.
If you do much with Master Documents, you do not create extra subfolders; if
you do, you can never move the master document because it breaks all the
internal links.
If you leave them all in the same folder, you can pick the folder up and
move it anywhere you like: the subdocuments will automatically re-attach
when the master is opened.
We'll all get a lot better at this in the next version. In the XML format,
master documents will finally be "fixed" so you can use them without
corruption. So finally, 20 years after it was invented, the Master Document
feature will be useful :-)
Cheers
On 14/5/06 3:39 AM, in article C08B67E0.CFFF0%berkowit@spoof_silcom.com,
"Paul Berkowitz" <berkowit@spoof_silcom.com> wrote:
--
Please reply to the newsgroup to maintain the thread. Please do not email
[snip]>
> I was just about to show you that it might be possible to do it using 'do
> Visual Basic' when I stumbled upon the fact that it _is_ possible to do it
> in regular AppleScript. It's just hidden away. No one knew how (except
> presumably the original developer, who never let on) - not even a Word
> tester very familiar with the AppleScript model! The secret is that after
> you set the view to master view:
>
[snipalot]
Thanks Paul, it's good to know that it does work properly with
Applescript.
And thanks for the example. Very useful. I have implemented it and found
it to be a lot quicker than the text parsing method (no surprisie). I
think the only advantage of my text parsing method now would be the
capability to extract a sub doc file name from the Heading 1 without
having to modify the heading itself (but only if that was important).
Thanks again. Job done and with a choice of methods!
Roger