Solved

Extract selective info from Word doc using VB

Posted on 2004-09-09
9
147 Views
Last Modified: 2010-05-02
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
Comment
Question by:sata
  • 5
  • 3
9 Comments
 
LVL 27

Accepted Solution

by:
jjafferr earned 125 total points
ID: 12023609
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
 
LVL 1

Author Comment

by:sata
ID: 12023678
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
 
LVL 1

Author Comment

by:sata
ID: 12023701
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
 
LVL 19

Expert Comment

by:akoster
ID: 12024920
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 19

Expert Comment

by:akoster
ID: 12024979
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
 
LVL 1

Author Comment

by:sata
ID: 12040602
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
 
LVL 19

Assisted Solution

by:akoster
akoster earned 125 total points
ID: 12041669
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
 
LVL 1

Author Comment

by:sata
ID: 12051125
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
 
LVL 1

Author Comment

by:sata
ID: 12051145
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now