Word automation using ASP.net RRS feed

  • Question

  • User-1948399394 posted


    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.



    Wednesday, September 17, 2008 5:18 PM

All replies

  • User-1948399394 posted

     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.

    Friday, September 19, 2008 11:35 AM
  • User-1199946673 posted

    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


    Friday, September 19, 2008 11:44 AM
  • User-1948399394 posted

    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.

    Friday, September 19, 2008 12:29 PM
  • User-1199946673 posted

    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?

    Friday, September 19, 2008 1:41 PM
  • User-1948399394 posted

     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.

    Friday, September 19, 2008 3:58 PM
  • User-1199946673 posted

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

    Friday, September 19, 2008 4:13 PM
  • User-1583229441 posted


    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. 

    Sunday, November 2, 2008 12:57 AM
  • User-1196000486 posted

     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

    Thursday, November 6, 2008 11:41 AM
  • User-1196000486 posted

     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 this helps:

            Object oMissing = System.Reflection.Missing.Value;

            Object oTrue = true;
            Object oFalse = false;

            Word.Application oWord = new Word.Application();
            Word.Document oWordDoc = new Word.Document();

            oWord.Visible = true;       

            //Get the document template (.DOT)file
            object oTemplatePath = "c:\\MyDocument\\Ticket.dot";
            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();



    Monday, November 24, 2008 11:57 AM