Last post Nov 24, 2008 11:57 AM by edski
Sep 17, 2008 05:18 PM|sanjupillai|LINK
I have a requirement for one of my clients where we have to generate licenses in word (.doc) format by inserting values into pre-formatted word template files (.dot). We have used bookmarks in the templates, which will be replaced by data from the database
based on the template selection. Now my question is - can we deploy this application on a web-server without having to install the MS-Word on the server? Almost all the sites i referred says we have to install MS-Word on the server in order to use the "Microsoft
Word 11.0 Object Library", that will be used for Word Automation using asp.net. Can anyone please help me on this and suggest is there any word around, which works without MS-Word installation on server.
Sep 17, 2008 07:14 PM|hans_v|LINK
Sep 19, 2008 11:35 AM|sanjupillai|LINK
Thank you hans for the post. But I don't want to go for another third party component. Will I be able to automate word from my asp.net application without installing word in the server and also without using aspose word or any other 3rd part component?
I want to utilize the Microsoft.Office.Interop.Word functionality. Please help.
Sep 19, 2008 11:44 AM|hans_v|LINK
You didn't say that you want it for free!
I don't think it is possible without a third party component, I never found a free one. Aspose is considered the best, it's even better than Office itself, since this is not designed for internet and could sometimes have unexpected behaviour!
Does the end result has to be a Word Doucment? If not, maybe you could consider to create PDF's on the fly? Those components are much cheaper, and some are also free, like
Sep 19, 2008 12:29 PM|sanjupillai|LINK
Yes, we need the end result in Word File. These are actually Original License Document for our clients. So we have the license templates with us in .dot format. We have placed bookmarks in these templates. No when creating the license files, we have to replace
the bookmarks with values from the database and create the .doc file. We have actually implemented this code using the Microsoft.Office.Interop.Word. But our client is sceptic about installing the office package on the server for this application. So is there
a way we can make this work without installing the whole office package, but the needed assemblies should be there on the server.
Sep 19, 2008 01:41 PM|hans_v|LINK
Why should a License Document be a Word Document? Very often these are PDF documents!
You can indeed using the Microsoft.Office.Interop.Word.dll on the server, Although I'm not sure about the legal implications. But as I said, using this dll in a web environment could cause unexpected behavior, as I understand reading some articles on this
subject. If you really need to do this, aspose is the best choice. What exactly is the reason not to use a third pary tool?
Sep 19, 2008 03:58 PM|sanjupillai|LINK
Thanks again [:)]. Actually the client's requirement was to implement the license as WorPerfect files. But when our efforts to work with WordPerfect failed we, convinced our client to change to MS-Word instead. The fact that they need to edit the original
license (adding comments), after it is generated, restricts our use of pdf for the license. But we have finished development of the application and are awaiting deployment in October. So now, it would be impossible to change the entire code for using aspose,
moreover client won't go in for another third party at this point. And also they are concerned about installing the Office package on the server.
Sep 19, 2008 04:13 PM|hans_v|LINK
I don't think it's necesarry to install Office, just registering the dll will do! But as I said before, I don;t know the legal implications, and the risk that it will cause unexpected behavior is there...
Nov 02, 2008 12:57 AM|bn_kh|LINK
Have you found a solution for this? I am trying to do the exact same thing. I have developed an appl using aspnet.vb with mailmerge function that connects to Words. I have use interop in my appl. Now i need to deployed it to the Server without Office.
How can I accomplished this? What are the dlls that i need to register?
Many thanks in advance.
Nov 06, 2008 11:41 AM|edski|LINK
Why insisting on third party products, is this not a developer's forum? There many examples for Excel, but few for Word. I'm interested myself, can someone show examples if this?
Try Not, Do, or Do Not. There is No Try...
(Yoda)- Master Jedi Knight
Nov 24, 2008 11:57 AM|edski|LINK
Well since now one could find an answer to this question for some time, I found a solution that worked on a test project I worked on. I could not supply all references I found this solution, but I must admit, there were not many. Here is what I have, hope
//OBJECT OF MISSING "NULL VALUE"
Object oMissing = System.Reflection.Missing.Value;
//OBJECTS OF FALSE AND TRUE
Object oTrue = true;
Object oFalse = false;
//CREATING OBJECTS OF WORD AND DOCUMENT
Word.Application oWord = new Word.Application();
Word.Document oWordDoc = new Word.Document();
//SETTING THE VISIBILITY TO TRUE
oWord.Visible = true;
//Get the document template (.DOT)file
object oTemplatePath = "c:\\MyDocument\\Ticket.dot";
//ADDING A NEW DOCUMENT FROM A TEMPLATE
oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
//oWord.ActiveWindow.Selection.Font.Size = 8;
int num = oWordDoc.Bookmarks.Count;
oWord.Selection.Font.Color = Word.WdColor.wdColorLime;
oWord.Selection.Font.Size = 8;
//Bookmarks "Prt_" within Word Doc
object oBMkTYPE = "Prt_Servtype";
oWordDoc.Bookmarks.get_Item(ref oBMkTYPE).Range.Text = type;
object oBMkTicket = "Prt_Wrktkt";
oWordDoc.Bookmarks.get_Item(ref oBMkTicket).Range.Text = Ticket;
object oBkMkSCustomer = "Prt_Sname";
oWordDoc.Bookmarks.get_Item(ref oBkMkSCustomer).Range.Text = SCust;
object oBkMkBCustomer = "Prt_Bname";
oWordDoc.Bookmarks.get_Item(ref oBkMkBCustomer).Range.Text = BCust;
object oBkMkADDRESS1 = "";
oWordDoc.Bookmarks.get_Item(ref oBkMkADDRESS1).Range.Text = txtAddress1.Text;
object oBkMkServiceTech = "Prt_Tech";
oWordDoc.Bookmarks.get_Item(ref oBkMkServiceTech).Range.Text = Session["login"].ToString();