From: Jeff Strickland Date: 2009-01-17T02:04:01+09:00 Subject: Re: Scraping off a Word document? "gregarican" wrote in message news:a7d21393-9d0b-4a90-9b0b-e58349e911b5@e10g2000vbe.googlegroups.com... > Here's a conceptual question. I have a Word mail merge, with a few > dozen documents. There's a certain field, let's call in the Employee > field, on each page. These documents are sorted in order of this > field. What I'd like to do is save off each group of pages into its > own Word document under that field. So if it's Employee: Joe Schmoe on > the first five pages I'd want to save off just those pages and name > the file "Joe Schmoe.Doc" and so on. > > The mail merge itself is pretty much hard-coded into a big group of > documents, so that's my basis. Any suggestions about what Ruby modules > and methods I'd start out delving into? I'm thinking win32ole of > course, but have a good-sized task ahead of me I have to deliver in > relatively short order :-/ I'm not sure you can do what you want to do. You open a Word doc, then want to save a portion based on the Employee Name to it's own file? Then, after that Save is finished, keep the file open, advance the database to the next Employee Name and repeat the save, then repeat the entire process until you get through all of the Employee Names? It occurs to me that Word can't do that task because the Employee Name field in the document is an unknown until the actual time of the merge. There is only one DOC file for any given letter, and when I do these kinds of merge all I get to see is where the variables are that get filled in during the merge. You have to fill the variable from the database then save the result, advance the database to the next record and fill the variable again to save that result. You are going to create a file for each employee for each letter, and this seems to me to defeat the whole reason to merge data into a document. The reason I merge is because I want one file for everybody, I specifically do not want a separate file for each person.