Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

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?
0
sata
Asked:
sata
  • 5
  • 3
2 Solutions
 
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
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
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.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now