locked
Populating Word Template RRS feed

  • Question

  • User-1196000486 posted

     I am testing an web form that when clicking submit, it will populate a Word 2003 Template with many bookmarks. When I test it on my local machine, the object gets called and populated beautifully, but on the server, the Word document does not get displayed. I don't know how to create an Active X control for the client side to handle it, so I am handleing it on the server-side, besides it is on a Intranet so security risks are minimal. Here is a snippet of my code:

           object oTemplatePath = "c:\\Template\\ServiceTicket.dot"; //path on Server Directory
           
           
            object oDocName = strCustName;
            object oDocFormat = "dot";

            //ADDING A NEW DOCUMENT FROM A TEMPLATE
            oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
            int num = oWordDoc.Bookmarks.Count;
            oWord.Selection.Font.Name = "Times New Roman";

            oWord.Selection.Font.Color = Word.WdColor.wdColorLime;
            oWord.Selection.Font.Size = 5;

            object oBMkTYPE = "Prt_Servtype";//1
            oWordDoc.Bookmarks.get_Item(ref oBMkTYPE).Range.Text = type;

            object oBMkTicket = "Prt_Wrktkt";//2
            oWordDoc.Bookmarks.get_Item(ref oBMkTicket).Range.Text = Ticket;

            object oBkMkSCustomer = "Prt_Sname";//4
            oWordDoc.Bookmarks.get_Item(ref oBkMkSCustomer).Range.Text = Cust;

            object oBkMkBCustomer = "Prt_Bname";//11
            oWordDoc.Bookmarks.get_Item(ref oBkMkBCustomer).Range.Text = Cust;

            oWordDoc.SaveAs(ref oDocName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

             many more bookmarks etc...........


            //SETTING THE VISIBILITY TO TRUE
            oWord.Visible = true;

    Or is there a better way???

    Edski

    Thursday, January 15, 2009 6:26 PM

Answers

  • User-319574463 posted

     Installing Word on a SERVER for unattended operation is not recommended by Microsoft. Can you log onto the server interactively and run Word?

    You will need to:

    • Check the event log
    • Run the COM explorer to set permissions on the various classes used by Word, so the ASP.NET process can access word.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 20, 2009 3:40 AM