Home All Groups Group Topic Archive Search About

Classic ASP question. Urgent !!!



Author
25 Sep 2006 2:53 PM
Victor
Hi, guys. We have a very old application that is written in classic ASP.
It's sitting on a very old server. I am supposed to do a migration of this
app to a new server. I copied all the files to a new server with Windows
2000 Server on it (actually it's a virtual server) and installed SQL Server
2000. The application works good, except for one little annoying thing. They
use an Office Automation in this application. The word document is created
based on some template and the values from SQL Server are inserted into this
document. So, on the old server when you click on the report, it
automatically generates a MS Word 2000 document and Opens it, so the user
can view it and saves it to a temp directory. On this new server we have MS
Word 2003 installed. So, when I click on the report, the Word document is
created in a Temp directory, BUT...  the document itself does not open
automatically for a user to view. Can anyone help me with this issue, please
? I don't know much about classic ASP or Office automation. I am a SQL
Server DBA, with some knowledge of .NET programming. But, I guess, at work
you have to do what you have to do. Please, help !!!

Thanks,

Victor.

Author
25 Sep 2006 4:14 PM
McKirahan
Show quote
"Victor" <victor***@gmail.com> wrote in message
news:ef7b56acce894cab921a798d70d07af3@ureader.com...
> Hi, guys. We have a very old application that is written in classic ASP.
> It's sitting on a very old server. I am supposed to do a migration of this
> app to a new server. I copied all the files to a new server with Windows
> 2000 Server on it (actually it's a virtual server) and installed SQL
Server
> 2000. The application works good, except for one little annoying thing.
They
> use an Office Automation in this application. The word document is created
> based on some template and the values from SQL Server are inserted into
this
> document. So, on the old server when you click on the report, it
> automatically generates a MS Word 2000 document and Opens it, so the user
> can view it and saves it to a temp directory. On this new server we have
MS
> Word 2003 installed. So, when I click on the report, the Word document is
> created in a Temp directory, BUT...  the document itself does not open
> automatically for a user to view. Can anyone help me with this issue,
please
> ? I don't know much about classic ASP or Office automation. I am a SQL
> Server DBA, with some knowledge of .NET programming. But, I guess, at work
> you have to do what you have to do. Please, help !!!
>
>  Thanks,
>
> Victor.

Could you post the relevant code?

Basicsally the subset of code referencing "Word.Application"; like:

    Const wdWindowStateMaximize = 1
    Set objMSW = CreateObject("Word.Application")
        objMSW.WindowState = wdWindowStateMaximize
    Set objDOC = objMSW.Documents.Open("C:\Temp\my.doc")
Author
25 Sep 2006 5:15 PM
VictorV
Here is the code:

openrs rs, sSql


        if rs.Recordcount <> 0 then

            dim strScriptName
            dim strFileName

            strScriptName = Request.ServerVariables("SCRIPT_NAME")
            strScriptPath = server.MapPath(strScriptName)
            strFileName = left(strScriptPath, instrrev(strScriptPath, "\")) &
GetParam("hdnReport")
            Dim app
            Set app = server.CreateObject("Word.Application")

            Dim doc
            Set doc = server.CreateObject("Word.Document")
            Set doc = app.Documents.Open(strFileName, , true)
            for each fld in rs.fields
                With doc.Content.Find
                    .ClearFormatting
                    .Text = "<<" & fld.name & ">>"
                    .Replacement.ClearFormatting
                    if isnull(fld.value) then
                        .Replacement.Text = ""
                    else
                        if len(fld.value) > 80 then
                        .Replacement.Text = left(cstr(fld.value), 80)
                        else
                        .Replacement.Text = cstr(fld.value)
                        end if
                    end if
                    .Forward = True
                    .Wrap = 1
                    .Execute , , , , , , , , , , 2
                End With
            next

            dim strTempFileName
            strTempFileName = replace(replace(replace(replace(now(), "/", ""), "\",
""), " ", ""), ":", "") & ".doc"
            strFileName = left(strScriptPath, instrrev(strScriptPath, "\")) &
"TempDocs\" & strTempFileName
            doc.SaveAs strFileName
            strFileName = left(strScriptName, instrrev(strScriptName, "/")) &
"TempDocs/" & strTempFileName

            doc.Close
            Set doc = Nothing
            app.Quit
            Set app = Nothing

Show quote
"McKirahan" wrote:

> "Victor" <victor***@gmail.com> wrote in message
> news:ef7b56acce894cab921a798d70d07af3@ureader.com...
> > Hi, guys. We have a very old application that is written in classic ASP.
> > It's sitting on a very old server. I am supposed to do a migration of this
> > app to a new server. I copied all the files to a new server with Windows
> > 2000 Server on it (actually it's a virtual server) and installed SQL
> Server
> > 2000. The application works good, except for one little annoying thing.
> They
> > use an Office Automation in this application. The word document is created
> > based on some template and the values from SQL Server are inserted into
> this
> > document. So, on the old server when you click on the report, it
> > automatically generates a MS Word 2000 document and Opens it, so the user
> > can view it and saves it to a temp directory. On this new server we have
> MS
> > Word 2003 installed. So, when I click on the report, the Word document is
> > created in a Temp directory, BUT...  the document itself does not open
> > automatically for a user to view. Can anyone help me with this issue,
> please
> > ? I don't know much about classic ASP or Office automation. I am a SQL
> > Server DBA, with some knowledge of .NET programming. But, I guess, at work
> > you have to do what you have to do. Please, help !!!
> >
> >  Thanks,
> >
> > Victor.
>
> Could you post the relevant code?
>
> Basicsally the subset of code referencing "Word.Application"; like:
>
>     Const wdWindowStateMaximize = 1
>     Set objMSW = CreateObject("Word.Application")
>         objMSW.WindowState = wdWindowStateMaximize
>     Set objDOC = objMSW.Documents.Open("C:\Temp\my.doc")
>
>
>
Author
25 Sep 2006 5:35 PM
McKirahan
"VictorV" <Vict***@discussions.microsoft.com> wrote in message
news:ED2441FA-3EF6-40C0-B2A4-166513764251@microsoft.com...

[snip]

> Here is the code:

[snip]

> Set app = server.CreateObject("Word.Application")
> Set doc = server.CreateObject("Word.Document")

You don't need the above line -- it's setting "doc" twice.

> Set doc = app.Documents.Open(strFileName, , true)

> > "Victor" <victor***@gmail.com> wrote in message
> > news:ef7b56acce894cab921a798d70d07af3@ureader.com...
> > > So, when I click on the report, the Word document is
> > > created in a Temp directory, BUT...  the document itself does not open
> > > automatically for a user to view. Can anyone help me with this issue,
> > please

Did you see this code from my last post?
What happens if you add it?

> >     Const wdWindowStateMaximize = 1
> >     Set app = CreateObject("Word.Application")
> >         app.WindowState = wdWindowStateMaximize

Oh, this code will close the document so they couldn't see it anyway.

Show quote
> doc.Close
> Set doc = Nothing
> app.Quit
> Set app = Nothing
Author
25 Sep 2006 6:52 PM
VictorV
Thanks for your help. It work now, but the problem wasn't code. Because code
worked on that old machine. All I had to do was to add this new intranet site
(the one on a new machine) to Trusted Sites in our group policy.

Thanks again,
Victor.

Show quote
"McKirahan" wrote:

> "VictorV" <Vict***@discussions.microsoft.com> wrote in message
> news:ED2441FA-3EF6-40C0-B2A4-166513764251@microsoft.com...
>
> [snip]
>
> > Here is the code:
>
> [snip]
>
> > Set app = server.CreateObject("Word.Application")
> > Set doc = server.CreateObject("Word.Document")
>
> You don't need the above line -- it's setting "doc" twice.
>
> > Set doc = app.Documents.Open(strFileName, , true)
>
> > > "Victor" <victor***@gmail.com> wrote in message
> > > news:ef7b56acce894cab921a798d70d07af3@ureader.com...
> > > > So, when I click on the report, the Word document is
> > > > created in a Temp directory, BUT...  the document itself does not open
> > > > automatically for a user to view. Can anyone help me with this issue,
> > > please
>
> Did you see this code from my last post?
> What happens if you add it?
>
> > >     Const wdWindowStateMaximize = 1
> > >     Set app = CreateObject("Word.Application")
> > >         app.WindowState = wdWindowStateMaximize
>
> Oh, this code will close the document so they couldn't see it anyway.
>
> > doc.Close
> > Set doc = Nothing
> > app.Quit
> > Set app = Nothing
>
>
>
Author
25 Sep 2006 8:35 PM
McKirahan
"VictorV" <Vict***@discussions.microsoft.com> wrote in message
news:6389B996-AFA2-4422-B8CD-CB13CB799BCE@microsoft.com...
> Thanks for your help. It work now, but the problem wasn't code. Because
code
> worked on that old machine. All I had to do was to add this new intranet
site
> (the one on a new machine) to Trusted Sites in our group policy.

[SNIP]

I'm glad you got it working.

I found another line of code that seems unnecessary:

      strFileName = left(strScriptName, instrrev(strScriptName, "/")) &
"TempDocs/" & strTempFileName

This is the line after
        doc.SaveAs strFileName
which has "strFileName" assigned just before it.
Author
26 Sep 2006 12:50 PM
VictorV
I agree. This application is very old, and a lot of code is junky. The vendor
that did this app doesn't exist anymore. I just inherited it and as long as
it still works, I am not touching it. Otherwise, I would have to rewrite it
completely.

Victor.

Show quote
"McKirahan" wrote:

> "VictorV" <Vict***@discussions.microsoft.com> wrote in message
> news:6389B996-AFA2-4422-B8CD-CB13CB799BCE@microsoft.com...
> > Thanks for your help. It work now, but the problem wasn't code. Because
> code
> > worked on that old machine. All I had to do was to add this new intranet
> site
> > (the one on a new machine) to Trusted Sites in our group policy.
>
> [SNIP]
>
> I'm glad you got it working.
>
> I found another line of code that seems unnecessary:
>
>       strFileName = left(strScriptName, instrrev(strScriptName, "/")) &
> "TempDocs/" & strTempFileName
>
> This is the line after
>         doc.SaveAs strFileName
> which has "strFileName" assigned just before it.
>
>
>

AddThis Social Bookmark Button