Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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

Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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

Reply With Quote
  #6 (permalink)  
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
Reply With Quote
  #7 (permalink)  
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
Reply With Quote
  #8 (permalink)  
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
Reply With Quote
  #9 (permalink)  
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)
Reply With Quote
  #10 (permalink)  
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..

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:53 AM.


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