Extract selective info from Word doc using VB

Hi,

I have this problem on hand that I'm not sure what should I do with it.

I have a user who use MS Word to mail merge in large quantities, contents are some medical information about each individual clients.

While mail merging them, then print out in hardcopy is fine, now the clients wants a PDF version of their medical information and to make distribution easy, the user decides to save each file using the id and name of the client.

But saving page by page is just too much for them, and they look to automation to help them.

After studying the possibilities, i thought maybe I will do this:

1. User mail merge into a document, run a program that will take this document(let's say sample.doc)  as the input.

2. User specify how pages does the template has.
3. I will run the document into one of those virtual printer that can convert the print into PDF files. If the user specify the template has 2 pages, then I will pass in to print page 1, 2 as doc1, print page 3,4 as doc2 until the end of sample.doc

The plan sounded ok for me, but I have a problem here: how to extract the name and id of the client from each print?

Can someone help me? Or maybe the plan above will never work and I should look for some other ways?
LVL 1
sataAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jjafferrCommented:
Hi sata,

Look at this link, where data are entered in Word,
you can flip the values and it can read from Word,

http://www.experts-exchange.com/Databases/MS_Access/Q_21023384.html

I hope this helps,

jaffer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sataAuthor Commented:
Hi Jaffer,

I have looked at the link, and tried putting the bookmark on the merge fields, then I save the file into .dot.
But somehow the bookmark doesn't seems to stay. Whenever I open a new doc using the .dot, the bookmark is not there already.

Or maybe I should not select the merge field when I'm inserting a bookmark?
0
sataAuthor Commented:
I tried inserting the bookmark somewhere else to try, and this time round the bookmark stays in the new doc when I open using the .dot, but once I mail merge the doc with data source, the bookmarks disappeared... did I miss something?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Arno KosterCommented:
When a single item can be found in a fixed place in the template (eg. the beginning), you can browse through the merged document. Each time you find the item indicating the beginning of the new user, print the old document to pdf and generate a new document beginning with the new user....
0
Arno KosterCommented:
in the template you can also generate the desired filename out of client name, date etc. Then filter the main document for this filename.
0
sataAuthor Commented:
akoster, I'm not sure how to execute your recommendation. what kind of "item" can I put in so that I can find the item indicating the begining of the new user?

Also, how can I generate the filename out of the client name and filter the main doc for it?

Can you be more explicit on the methods that I can use? Thanks!
0
Arno KosterCommented:
well, let's say you add a line to the template which states something like "<NEW PAGE>".
in the code executed to determine the right layout you browse the text line by line.
When the browsed line contains the words <NEW PAGE> you know that a new document has to be made.
When the browsed line does not contain those words, append the line to the newest document.
When all lines are browsed and thus all client data has been processed you can print the files to pdf one by one.

Extending this, you could for example filter the browsed lines for client names or add something like <CLIENT NAME> bla di bla to the mail merge template. Having identified the client names / adresses / something else, you could use this information to build filenames.


eg :

pos = instr(text_line, "<CLIENT NAME>")    // returns the position at which the tag is found or zero if not.
client_name = mid(text_line, pos + 14)      // returns the characters following the tag (length of client name tag=14)
FileName = Format(Date, "yyyy-MM-dd") & " " & client_name & ".pdf"

0
sataAuthor Commented:
I figured if I put the data into a table, I can look for the info by specifying the cell in the table that I want the data.

so getting the data part should now be fine. Thanks.
0
sataAuthor Commented:
Although I didn't exactly follow you guys recommendation, but you give me the clue of what can be done. So thanks to both of you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.