Solved

Extract selective info from Word doc using VB

Posted on 2004-09-09
9
150 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 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