Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006
    Posts
    3

    Unanswered: Problem With MS Word DCOM on ASP Page

    Hi there

    I have a problem with winword.exe on my server. i have an asp page which populate a word template on my web server using bookmarks which works fine
    but for some reason it does not close the winword.exe on the server after the document has been populated and saved and i end up with lot of these running in the server taskmanager which i have to close down manually what make this even stranger is that when i test it on my laptop the winword.exe are close after the page has ran

    please see my code below

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!-- #INCLUDE FILE = "../../DB/DBConnect.asp" -->
    <% Session.LCID = 2057 %>
    <%
    On error Resume Next
    Server.ScriptTimeout = 100000
    Dim PrimKey

    PrimKey = Request.QueryString("PrimKey")

    Dim rs
    set rs = Server.CreateObject("ADODB.Recordset")

    SQL = "SELECT * FROM tbl_ASR " & _
    "WHERE PrimKey = '" & PrimKey & "';"

    rs.Open SQL,objConn,2,3

    Dim FileName
    FileName = rs("FirstName") & "_" & rs("Surname") & "_" & rs("Payroll") & "_" & rs("CostCentre")

    Dim wdApp
    set wdApp = Server.CreateObject("Word.Application")

    'Server
    wdApp.visible = true

    Dim wdDoc
    strPath = Server.MapPath("\Transactional_Services\Subsites\A SR\Template\ASR.dot")

    set wdDoc = wdApp.documents.open (strPath)

    If wdDoc.Bookmarks.Exists("Name") Then
    wdDoc.Bookmarks("Name").Range.Text = " " & rs("FirstName") & " " & rs("Surname")
    End IF

    If wdDoc.Bookmarks.Exists("JobTitle") Then
    wdDoc.Bookmarks("JobTitle").Range.Text = " " & rs("JobTitle")
    End IF

    If wdDoc.Bookmarks.Exists("PayrollNumber") Then
    wdDoc.Bookmarks("PayrollNumber").Range.Text = " " & rs("Payroll")
    End IF

    If wdDoc.Bookmarks.Exists("Directorate") Then
    wdDoc.Bookmarks("Directorate").Range.Text = " " & rs("Directorate")
    End IF

    If wdDoc.Bookmarks.Exists("Location") Then
    wdDoc.Bookmarks("Location").Range.Text = " " & rs("Location")
    End IF

    If wdDoc.Bookmarks.Exists("CostCentre") Then
    wdDoc.Bookmarks("CostCentre").Range.Text = " " & rs("CostCentre")
    End IF


    wdDoc.saveas Server.MapPath("\Transactional_Services\Subsites\A SR\ASR_Documents\" & FileName & ".doc")

    wdDoc.Quit
    wdDoc.Close
    Set wdDoc = Nothing

    wdApp.Quit
    wdApp.Close
    Set wdApp = Nothing

    rs.close
    objConn.close
    set rs = Nothing
    set objConn = Nothing

    Response.Redirect("ASR_Documents/" & FileName & ".doc")

    %>

    If any body can give me any hint tip or knows how to solve this problem PLEASE HELP

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    DO NOT USE OFFICE AUTOMATION ON A WEB SERVER.

    It is very, VERY bad ju-ju.

    As you've noticed, the second you start threading out automation you tread into unmanaged code territory and end up with bizarre behavior if you have more than one user. I would very strongly recommend you find a solution that does not involve automation on your webserver.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Nov 2006
    Posts
    3
    Teddy

    What would you recommend then instead of office thats just what i have avilable where i work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •