Wrox Programmer Forums
|
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
 
Old June 29th, 2004, 03:08 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 :)
 
Old June 29th, 2004, 03:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old June 29th, 2004, 04:07 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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..

 
Old June 29th, 2004, 04:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old June 29th, 2004, 08:47 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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



 
Old June 30th, 2004, 02:20 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old July 1st, 2004, 12:31 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Office Automation- open word document ayazhoda Access VBA 2 November 4th, 2008 12:01 PM
open word document and insert data PorcupineRabbit Visual Basic 2005 Basics 1 August 9th, 2007 06:31 PM
Editing Server side Word document narendrapawar VB How-To 1 April 1st, 2005 12:10 PM
open, change a excel document from word kareltje Excel VBA 2 February 14th, 2005 11:23 AM
Creating MS Word File at Client Side zaeem Classic ASP Components 1 November 2nd, 2003 07:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.