Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone !

I have a simple question ... I think LOL

I have : a C# Windows Form App that inserts, updates and retrieves information from an SQL Database. I've found a lot of useful information on the forums here and so far, the project is going pretty well. I don't plan on selling it or distributing it btw, it's just for my small business. I was even able to program a POS that transfers data to my accounting software.

So.. the project is almost over, but now I'd like to be able to print my contracts and invoices. I have a contract template (that I fill out by hand at the moment), it's in .doc

I'd like to know what the best (invisible and silent) way to insert data in my documents would be. By invisible and silent, I mean I don't want like Word to open and have to click print in there.

I'd just like to push a print button, fetch the data, have C# insert it into the template and print it.

So far, I know I have to build a template doc file (save it in which format?)

I've read posts and a little MSDN about using this:

C#
WordApplication.ActiveDocument.Bookmarks["BookmarkName"] .

but I can't figure out if I'll get the results I want with that.

Once again, thank you very much for the help. I can't say enough about how much I appreciate it.
I'm looking around the new posts and trying to help people if I can, but I'm still a "noob". I'll get there someday and be I"ll be able to help back *promise*
Posted
Comments
Boipelo 25-Jul-13 14:29pm    
Adding to the below answer; there is word automation and pdf(itextshrp) articles here on codeproject. Search them, I once used both, thy do wonders.

1 solution

Quote:
I'd like to know what the best (invisible and silent) way to insert data in my documents would be.


Putting all of your code into a separate thread would make it "invisible and silent"

Quote:
I'd just like to push a print button, fetch the data, have C# insert it into the template and print it.


Their is no need to push a button because you can use a print dialogue.

Also
WordApplication.ActiveDocument.Bookmarks["BookmarkName"]
is when you have a word document plug in application.

If I were you I would instead use a hidden richtext box be your template (so nobody see's it) and do what you want with the data.
 
Share this answer
 
Comments
Luthecia 25-Jul-13 15:06pm    
Wouldn't that mean I'd have to rebuild my whole UI?
[no name] 25-Jul-13 17:16pm    
If I understanded your answer correctly all the data is in the SQL database. Instead of putting it in a doc put it into a rich text box.
Luthecia 28-Jul-13 19:01pm    
Ok, now I get what you mean.

I'll try that, thx a lot !!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900