 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 29th, 2004, 03:08 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cannot open Word Document At Client Side
Hi All,
I am trying to open MS word document by using vbscript. The code works fine at server side. But, at client side, the MS word object is initialised but nothing is happening as I can find winword.exe in the Task Manager. Here is my codes:
'-------code start--------------
<%
Sub RetrieveOne(cnDB)
id=request("id")
%>
<Script Language="vbscript">
docpath = "C:\Inetpub\wwwroot\system\Proposal\<%=id %>.doc"
Set wApp = CreateObject("Word.Application")
Set oDocument = CreateObject("Word.Document")
On Error Resume Next
Set oDocument =wApp.Documents.Open(docpath)
If Err.number = 0 then
wApp.Visible = True
wApp.Documents(1).Activate
Set wApp = Nothing
End If
</script>
<%
End Sub
%>
'-------code end---------------
At the same time, I have already enable "Initalizing and Scripting ActiveX controls that are not marked safe" under Trusted Sites/Custom Level.
Hope can get reply from you all. Thanks in advance :)
|
|

June 29th, 2004, 03:23 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
What exactly are you trying to accomplish? Are the client and the server the same machine?
If not, this code is not going to work. Your docpath variable points to a path at the server, not the client.
What happens when you comment out On Error Resume Next? That allows you to see the error. And why are you trying to open a Word document like this? Isn't it easier / safer / better / cleaner / whatever to just provide a link to a .doc file and let the client handle the document? What about someone without Word installed or without the lowered security privileges??
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

June 29th, 2004, 04:07 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
Thanks for ur suggestions.
Do u mean something like below:
'--------------
<a href='vbscript:OpenDoc("Sample.doc")'>Sample Document</a>
'-------------
Can the code above open word document that reside at server with path at server?
Thanks again..
|
|

June 29th, 2004, 04:31 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I was referring to something even simpler:
<a href="/Path/To/Your/Document.doc">Download this Document</a>
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

June 29th, 2004, 08:47 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Imar.
I have tried ur idea. But I found that it only works
at server side. Blank IE is opened at client side. FYI, Client and Server reside different machine.
Have a nice day :)
|
|

June 30th, 2004, 02:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, you have to make sure that /Path/To/Your/Document.doc is a virtual path. That is, the Word document needs to live within your Web site somewhere.
You can't set the href to, say, "c:\YourPath\WordDocument.doc". That would work on the server (it has that c:\YourPath folder) but not on the client.
If that doesn't help, can you post your code?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

July 1st, 2004, 12:31 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you so much Imar.
Exactly, the mistake is the path. I changed to something like "http://server ip address/path/Document.doc". It works now.
Thanks for ur help and kindness. Have a nice day :)
|
|
 |