Inserting Variables in a Document

R

Ryan

Ok.. here's my situation. I have a program that handles a database full of
people. Users of the program have the ability to send out notifications to
these people. Pretty standard notifications, the program tracks when
notifications are sent out and who sends them. Currently these
notifications are all sent via email.

Now the program users also want the ability to send these notifications via
standard snail mail. (I'll make a popup box come up "Do you want to print
this notification?") I want to allow the users the ability to modify these
notifications as well so that will not have to be done programmatically
if/when notification wording changes. The notifications need to allow for
variables to be insert into the document .. for example, the persons name,
address, salutation, etc. The document needs to have the capability to
print not only the document but a mailing envelope as well so my first
thought as to the document medium is to use Microsoft Word.

Originally my plan was to just have the program save the location (selected
by the user) of a Microsoft Word document. The Word document opens and the
user manually enters the recepient information. This, however, is an
undesirable solution. The users really want the information to be imported
programmatically, somewhat like a Word mail merge (except it only needs to
handle one user at a time). So my next thought is to create a Word document
dynamically every time a user opts for a printable document. Not sure if
this is ideal either because I'm not sure how I'll allow the users to edit
these documents seeing as how they don't exist as a document, I'd probably
save the document body information in a database and allow the users to
modify that. Anyways, just looking for some ideas here. Is there any way
to create a Word document and use variable fields (example: <<First Name>>,
<<Last Name>>, etc.), then have my program open that document and insert the
variable data? Are their any other output solutions (besides Microsoft
Word) I should be looking at?

Thanks for any suggestions,
Ryan
 
P

Peter Huang [MSFT]

Hi Ryan,

I think you may consider the VSTO which is introduced from VS.NET 2005.
We have a special BookMark control in VSTO project, we can use that as the
insert variable.
And it support DataBinding which will easierly to connect it onto database.

http://www.officezealot.com/VSTO/videos.aspx

http://blogs.msdn.com/vsto2/archive/2004/04/29/123027.aspx

http://blogs.msdn.com/pstubbs/archive/2004/09/03/225513.aspx

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Ryan

VSTO is a separate product from VS 2005 Pro correct? (so it would require
the purchase of more software)

I had another thought this morning. Maybe I'll export the data from the
notification to an Excel file. From there, the user can easily perform
their own mail merge in Word manually.

Ryan
 
P

Peter Huang [MSFT]

Hi Ryan,

You are correct.
The VSTO is included in the VSTS version of VS.NET 2005. Or you may buy a
Visual Studio Tools for Office System develop tools stand alone package.

Word Mail Merge is an approach as you said.

Also I think you may try to consider the Smart Document which is somewhat
complex than VSTO, but you may have a look.

Smart Documents Made Easier for .NET Developers
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/ht
ml/odc_SmartDocsWrapper.asp

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

bob

Ryan,

I'm not quite sure what you want to do here. Maybe you don't need any
sophisticated Word programming, though. If your program already has the
list of names/addresses in its database, as well as the text of the
notices, then you could insert everything into a text file, then open
it in Notepad so the user could print it.

If the notice text is in one or more separate documents, you could put
placeholders in the text (such as ??name, ??addr1, ??city, etc.) and
your program could open the text file, put it into a string, and then
do a Replace function for each placeholder.

Of course, if you have tens or hundreds of names in the database and
users have to send the notice to many people at one time, that wold
probably best be handled by programming Word to do a mailmerge.

Good luck!
 
B

bob

Peter,

I just clicked on your link to "smart documents made easier" and got a
message "Page Not Found". I might be interested in "Smart" documents so
if you have a better link I'd like to know what it is. Thanks.
 
R

Ryan

The document needs to be able to print an envelope too.. and notifications
could be sent to multiple people (I know I said before one person at a time
but I may change this). I'm really starting to lean towards the export data
to excel, allow the user to perform a mail merge idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top