Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Classic ASP question. Urgent !!!

Reply
Thread Tools

Classic ASP question. Urgent !!!

 
 
Victor
Guest
Posts: n/a
 
      09-25-2006
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.
 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      09-25-2006
"Victor" <> wrote in message
news:. ..
> 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")


 
Reply With Quote
 
 
 
 
VictorV
Guest
Posts: n/a
 
      09-25-2006
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

"McKirahan" wrote:

> "Victor" <> wrote in message
> news:. ..
> > 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")
>
>
>

 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      09-25-2006
"VictorV" <> wrote in message
news:ED2441FA-3EF6-40C0-B2A4-...

[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" <> wrote in message
> > news:. ..
> > > 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



 
Reply With Quote
 
VictorV
Guest
Posts: n/a
 
      09-25-2006
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.

"McKirahan" wrote:

> "VictorV" <> wrote in message
> news:ED2441FA-3EF6-40C0-B2A4-...
>
> [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" <> wrote in message
> > > news:. ..
> > > > 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

>
>
>

 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      09-25-2006
"VictorV" <> wrote in message
news:6389B996-AFA2-4422-B8CD-...
> 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.


 
Reply With Quote
 
VictorV
Guest
Posts: n/a
 
      09-26-2006
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.

"McKirahan" wrote:

> "VictorV" <> wrote in message
> news:6389B996-AFA2-4422-B8CD-...
> > 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.
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Classic ASP inside a dot net portal - Urgent talkingwall ASP .Net 6 07-11-2005 11:54 PM
LOOP through an ASP form's pages (not ASP.NET - ASP classic) David A. Beck ASP General 10 04-13-2004 05:38 PM
RE: Need to replicate Classic ASP in ASP.NET using Datagrid Mike Moore [MSFT] ASP .Net 0 01-09-2004 12:47 AM
Re: Need to replicate Classic ASP functionality in ASP.NET using Datagrid Marina ASP .Net 2 01-07-2004 09:56 PM
Re: Classic ASP to ASP.Net XMLHTTP S. Justin Gengo ASP .Net 0 08-27-2003 04:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57