Forum Moderators: open

Message Too Old, No Replies

Cannot Open Word Document at Client Side

vbscript and MS Word

         

leo_ling

7:56 am on Jun 29, 2004 (gmt 0)

10+ Year Member



Hi,
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 :)

Easy_Coder

12:15 pm on Jun 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try removing your Error Handler to see if an error is attempting to bubble to the surface:
-->On Error Resume Next

leo_ling

1:14 am on Jun 30, 2004 (gmt 0)

10+ Year Member



Hi,
I have tried to remove the "on error resume next". But same things happened.

Easy_Coder

2:54 pm on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



loe_ling -

Add an else to this code to make sure that you trap all conditions...
If Err.number = 0 then
wApp.Visible = True
wApp.Documents(1).Activate
Set wApp = Nothing

Else
'why am I getting an error and what is it?
response.write err.number & "<br>" & err.description
End If

Also, look into your browser security settings and make sure that your not running into an obstacle there.