Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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 August 3rd, 2004, 06:55 AM
Authorized User
 
Join Date: Jul 2004
Location: New Delhi, Delhi, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sherbir
Default How to open .DOC in MS-Word file thru a link ?

I have an application that supports uploading and downloading of .DOC files designed in servlets.

Everything works fine.

My problem is the downloading part.

When I click a link, eg..<a href="/path/to/the/.doc/file">, the file opens succesfully...but in the browser and not MS-Word.

I want MS-Word application to open and then that file to be called in MS-Word.

I do not want to display the file in the browser.

Any suggessions using Javascript or JSP ?

Please Help.

Thanx alot

Regards,
Sherbir
__________________
Regards,
Sherbir
 
Old August 3rd, 2004, 08:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I believe that you have to download it to your machine for that to work. Every doc I've seen loads in the browser, even if you specify target="_blank".

Brian
 
Old August 3rd, 2004, 08:23 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Sherbir,

You can do it in IE, but your clients will need to set their browser settings to allow scripting of unsafe ActiveXObjects in your pages (this maybe ok for an intranet, but IMHO only the truly stupid would trust this in a public website)...

Code:
<script type="text/javascript">
var wordApp = new ActiveXObject("Word.Application");
wordApp.Visible = true;
wordApp.Documents.Open("[UrlOfWordDocument]");
</script>
HTH,

Chris

 
Old August 3rd, 2004, 11:50 PM
Authorized User
 
Join Date: Jul 2004
Location: New Delhi, Delhi, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sherbir
Default

Quote:
quote:Originally posted by ChrisScott
 Hi Sherbir,

You can do it in IE, but your clients will need to set their browser settings to allow scripting of unsafe ActiveXObjects in your pages (this maybe ok for an intranet, but IMHO only the truly stupid would trust this in a public website)...

Code:
<script type="text/javascript">
var wordApp = new ActiveXObject("Word.Application");
wordApp.Visible = true;
wordApp.Documents.Open("[UrlOfWordDocument]");
</script>
HTH,

Chris

Hey Chris,
Thanx alot 4 ur advise. Actually I searched alot on the Internet also 4 this stuff and found that the idea u gave was quite useful.

I have implemented the same in my servlet but therez a problem...
I get an error saying that 'Automation server can't create object'...when I use the ActiveXObject thing.

Y's that so ? Any idea ?

How do u suggest I should remedy the situation ?

Regards,
Sherbir
 
Old August 4th, 2004, 03:17 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Sherbir,

You need to allow scripting of unsafe ActiveX controls, otherwise IE will prevent you creating the word application object.

In IE tools -> Internet Options -> Security -> Custom Level, there is a setting "Initialize & script ActiveX controls not marked as safe", set this to prompt or enable.

But be sure you only allow this for sites you trust, otherwise somebody could seriously damage your machine.

Cheers,

Chris

 
Old January 26th, 2005, 02:46 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I appear to have the opposite problem.

I'd like to get a spreadsheet to open in the browser but it keeps opening up Excel

The code looks like this

<a href="Operator.xls" target="_blank">Operators</a>

I've tried javascript pop ups but that only seems to work for 'htm extension?

jake
 
Old January 26th, 2005, 09:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can use the Active X approach - see http://www.greggriffiths.org/webdev/both/excel/ - otherwise you need to configure IE so that it handles them in the way you want - seesee http://support.microsoft.com/default...NoWebContent=1
 
Old January 27th, 2005, 06:30 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Greg:D
 
Old January 27th, 2005, 10:42 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If lowered security settings are not possible then you may be able to adapt this approach:
http://support.microsoft.com/default...;EN-US;q260519
Your users can then open or save the document but it shouldn't open in the browser.


--

Joe (Microsoft MVP - XML)
 
Old February 16th, 2005, 04:16 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The fix is a mere 2 second job - go to a Folder then click on Tools | Folder Types | File Options and go down to DOC, click on Advanced and remove the checkbox from 'Browse in same window'. You're now fixed..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a MS Word doc saved in a database cmw2992 Classic ASP Databases 0 November 26th, 2007 01:22 PM
Convert Ms Access report to MS Word doc kite Access 1 October 22nd, 2007 01:45 AM
Need to Preview a MS Word Doc GAF General .NET 2 November 11th, 2005 03:13 PM
How to open .DOC file with MS-Word thru a link ? sherbir Servlets 0 August 3rd, 2004 07:03 AM
How to open a .DOC file with MS-Word ? sherbir Servlets 0 July 26th, 2004 02:39 AM





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