Last post Jan 20, 2009 03:40 AM by TATWORTH
Jan 15, 2009 06:26 PM|edski|LINK
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???
Jan 20, 2009 03:40 AM|TATWORTH|LINK
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: