Re: NEWBIE:splitting multi-page word doc into single word doc - th
- From: aq4word <aq4word@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 16 Nov 2007 08:00:04 -0800
Hi Doug
Have just used your macro for splitting large files. Excellent. Thank you
for that. I have split a 240k file (a Scrabble dictionary that has about 50%
erroneous spellings per MS Spellcheck) into 43 smaller files (page 1, page 2,
etc.). I have then applied Greg Maxey's macro for deleting wrongly spelled
words (Thank you Greg) on just one file, (i.e. Page 1). Works fine, took
about 3 hours.
Question - Is it possible to batch process the other 42 files with Greg's
macro instead of doing them one by one?
"Doug Robbins - Word MVP" wrote:
Sub splitter().
'
' splitter Macro
' Macro created 16-08-98 by Doug Robbins to save each page of a document
' as a separate file with the name Page#.DOC
'
Dim Counter As Long, Source As Document, Target As Document
Set Source = ActiveDocument
Selection.HomeKey Unit:=wdStory
Pages = Source.BuiltInDocumentProperties(wdPropertyPages)
Counter = 0
While Counter < Pages
Counter = Counter + 1
DocName = "Page" & Format(Counter)
Source.Bookmarks("\Page").Range.Cut
Set Target = Documents.Add
Target.Range.Paste
Target.SaveAs FileName:=DocName
Target.Close
Wend
End Sub
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"patti" <patti@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2280C825-3B37-4A1C-928D-2FD59155722D@xxxxxxxxxxxxxxxx
Hi,
Environment: Windows XP/ home edition; sp2
Office 2000 [no help installed and no cd to install help :-( ]
experience: newbie to vba, c coding experience
This request is free of charge for a friend who would do anything for
anyone. His hard drive of clients was hosed and is able to retrive it
from
another source. Unfortunately, the files retrieved are not named
properly
and incompatible with his business operations.
Problem description/vba coding segment requested:
Over 60 documents named xxxxxnnnn.doc that contain client info, delimited
with over 65 page breaks. Within each page break contains the client
info,
which needs to be extracted into their own word document, and take on the
name: client_name_date_of_service.doc to easily distinguish it.
Relevant client information (including ultimate file name) is contained
within each page break in the larger document. Last record in original
file
may not contain the page break, but I'd still like to be able to capture
this
one as well.
Filename containing relevant client information should be of the form
client_name_date_of_service.doc (this information is contained within each
page break)
Objective:
- Cycle through all the word documents (approx 60 files) in a given
folder
-for each large document file (over 60 files) -- start the splitting
process
- open each file
- for each page break found (between 65 - 80 page breaks)
- for each paragraph in each page break
- capture the first line of each page [this is the client
name]
- for each paragraph [search for the string "date"]
- generate the client name (eg.joe_smith_1_24_07.doc) and
save in a string variable
- capture the entire page
---> including final page break for each page
---- select the contents of this page break and copy the
entire page,
including trailing page break [if absolutely
necessary,]
into client_name_date_of_service.doc.
(eg. joe_smith_1_24_07.doc)
- next [for each page break until no more page breaks in this
file
-- note: the final client info. may not contain the trailing
page break,
but I'd still like to be able to capture it and
store it in its proper
clientname_date_of_appt.doc
- next [for each file containing all the client data within the page
breaks]
- close/properly dispose of any allocated resources
- error handler to close/dispose to determine the cause of the
failure
and properly shutdown the application.
?? any additional steps that I've neglected to mention.
I enjoy helping people and learning new things. Many thanks to all who
take the time to share their time and talents by responding witih the code
capable of accomplishing this task.
With much gratitude and appreciation,
Patti
- Follow-Ups:
- Re: NEWBIE:splitting multi-page word doc into single word doc - th
- From: Doug Robbins - Word MVP
- Re: NEWBIE:splitting multi-page word doc into single word doc - th
- Prev by Date: Re: Please help:need to read XML, edit, and write back to XML file
- Next by Date: Re: printing current page not working properly
- Previous by thread: Drop Down List Widths
- Next by thread: Re: NEWBIE:splitting multi-page word doc into single word doc - th
- Index(es):
Relevant Pages
|