Link to home
Start Free TrialLog in
Avatar of mikesandra
mikesandra

asked on

How Do You Force a .doc Link to Open Up in Word not a Browser in Flash

I am using the getURL in Flash to open up a word document in a separate window.  How do you force it to open up in Microsoft Word not Internet Explorer.  What code can I put in the "GetURL" actionscript to do this?
Avatar of CyanBlue
CyanBlue
Flag of United States of America image

Howdy...

You cannot specify the program that opens up the file...  Flash file being a part of the web browser, web browser opens up the given file(*.DOC in this case) into the program that is specified in the MIME type which is the web browser itself... and you cannot change the MIME type to bypass that either...

CyanBlue
Avatar of ch2
ch2

Cyanblue is right, but if your server runs with php or asp you can do like this:

In ASP

getURL('wordocument.asp');

Put the following line on the top of your ASP page:
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-word"
Response.AddHeader "content-disposition", "inline; filename = word.doc"
%>

In PHP

getURL('wordocument.php');

<?php
header("Content-type: application/msword");
header("Content-Disposition: attachment; filename=word.doc");
readfile('test.doc');
?>
The easiest way to force a word.doc to download (rather than open in IE) is to wrap it in a .zip file and link the to the .zip instead.
Avatar of mikesandra

ASKER

ch2 I tried your way but it keeps on trying to open  up the asp page in dreamweaver rather than opening up the word document in word.  Any ideas why?
Try this, change word.doc to your choice.

<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "content-disposition", "inline; filename = word.doc"
%>
I just tried that and now it opens up a blank word document within IE.  Any other ideas?

below is the code I'm using for my asp page "hractive.asp"
<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "content-disposition", "inline; filename = hractive.doc"
%>

Here's the code in my flash file

on(release){
getURL("http://207.239.169.170/hractive.asp")      
}
This one should work.

<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment; filename = word.doc"
%>
Unfortunately, its trying to open up the hractive.asp file in dreamweaver still.
Sorry i'm more into php. Try the next code.

<%
Dim objStream, myContents, myFileName

myFileName = "word.doc"

Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" & myFileName

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.LoadFromFile Server.MapPath(myFileName)

myContents = objStream.ReadText

Response.BinaryWrite myContents

objStream.Close
Set objStream = Nothing
%>
You need to run the asp file on a webserver and view it in a browser. You can't just click double click it.
But always make sure to use the correct path to the file.

Mike
blockage1 - what do you mean "you can't just double click it".  ch2 I tried all of your solutions and they all continue to try and open up the asp file in dreamweaver.  

The button I have in Flash has this code that connects to the asp page;

on(release){
getURL("http://207.239.169.170/hractive.asp")      
}

is there a different way I should be doing this?
Try changing the next line in the code on my last post.

Response.ContentType = "application/octet-stream"
to
Response.ContentType = "application/ms-word"
or
Response.ContentType = "application/msword"


If the above dosen't work you may search EE or ask in the ASP forum how to do it.

Before this post you could't even force the download. So you are in the right diection.
It worked when I started it off from an HTML page.  It just doesn't work when i start it off from a shockwave file.  The asp code is working fine.  The issue is Flash.  That's why I asked the question in the Flash forum.  Any idea's why its not working correctly when starting in a shockwave movie?
This is the html page that works correctly;

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<a href="hractive.asp">Download File</a>
</body>
</html>

This is the code behind the button in Flash (shockwave)

on(release){
getURL("hractive.asp")      
}

Why are they behaving differently?  They are both linking to the same place.
Cyanblue explained above.

You can only change the mime type from server-side, because getURL only get text/html not word or any other type.
Can't I link from within my flash to an html page that automatically brings you to the asp page?
The only reason I want to open up this file in word and not just keep it in the browser is because I want users to be able to send the word document as an attachment through email.  If someone can tell me how to do that though IE I'd be very happy.
As I said before put it in a zip file
To get the many asp and php examples working you must be running a web server. None of the examples will work on your pc with out a webserver.
I don't think I like the zip file idea.  We have about 500 users in our company and I think they would be confused with a zip file.  Maybe you can better explain how that would work.
I am running it on a webserver.  I did get it to work with an html file.  It just doesn't work when the link is originated from a shockwave file.
Well your users connects thru a webser? my method works 100% correct. I think you are trying this with an satndalone swf and will never works. You must try in the server because is the way your users will see. If you want and standalone app, use a swf projector.

Your flas should look like this:

on (press) {
      getURL('Document.php');
}

Document.php with the code i posted above.

The swf file have to be embed into an html page like the below one and then uploaded to the server. When the users get on this page and press the flash button to download, the breowser will promt which action you want to take on the file.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Word</title>
</head>
<body>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400" title="s">
  <param name="movie" value="mymovie.swf" />
  <param name="quality" value="high" />
  <embed src="mymovie.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed>
</object>
</body>
</html>
Is the swf being served from your webserver? Testing via preview movie probably wont work either.

Zip files are pretty common place and can be opened in xp with out any software. I suggest you do a test, by putting your word doc into a zip file and downloading it - you'll see its pretty easy to use. The other benefit of using a zip file is it will be a faster download.
Let em explain.  I am developing intranet.  The intranet application we purchased has a horrible HTML editor.  So I'm not using any HTML pages.  I am only using shockwave files if you can believe it.  But at least it looks good.  And everybody here at work has the Flash Player 8 so its fine.  But I'm thinking the only way I can do this if I link it to an html page that automatically jumps to the asp page.  Do you think that would work?
The only way to work this i think, is embending the object in an html fla, removing the file association for word files on all computers. or installing Firefox on all computers and configure it to choose an action for word files.

I would embed the flash in a tiny HTML code like the one i posted.

Don't know if there is other method.
OK thanks for all of your help.  But I don't think there is a way to do this.  I can't use HTML pages, i can't remove the file association on all computers, and I can't install Firefox on all computers (i don't think our IS department would like that).  Thanks anyway. if anyone else may have an idea please let me know.  Thanks.
I don't think this what you'll want to hear but you should look at basecamp - its cheap, easy to use and probably has lots more functionality than you'd be able to build. http://www.basecamphq.com/
Forget the all above.

You are trying to acces the file locally now try passing it with the server.

on(release){
getURL("http://yoursite.com/hractive.asp")    
}

I think this should do the trick.
ch2 - i've tried that before.  I thought that would work but it wants to still download the hractive.asp page not the word document.  Thanks anyway.  any other ideas?
If browser want to download hractive.asp means you don't have ASP enabled or you have an error on the script. Download hractive.asp and open it..

I tested in PHP and ASP and worked.
when i download it - it says its downloading the hractive.asp page to dreamweaver.  

When i look at the file in dreamweaver, it looks like its trying to open the word document in dreamweaver.  It comes up with this gobbliguck.

ÐÏࡱá>þÿ      ^`þÿÿÿ]ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥ÁM       ø¿ôbjbjâ=â=      .R€W€W¢

ÿÿÿÿÿÿl0000¤¤¤¸ŽŽŽ8Æ´z,¸Õ(B²ÂÂÂÂØ<4HœÜ'Þ'Þ'Þ'Þ'Þ'Þ'$* 7,j(¤äX|Ôää(T00–(TTTä,0V lÂÜ'TäÜ'Tt      TÈ'††x,È'¦ €%´hñǸ֎DÈ'È'¥(0Õ(È'¡,T¡,È'T¸¸0000ÙHUDSON CITY SAVINGS BANK
EMPLOYEE ACTION FORM – ACTIVE EMPLOYEE (STATUS 1)

CURRENT EMPLOYEE INFORMATION

Branch Management: Complete this section and email to Regional Manager and ARM.
Department Management: Complete this section and email to Human Resources Department and Retail Systems Administration Department.

First Name:       FORMTEXT                  MI:       FORMTEXT               Last Name:       FORMTEXT            
the asp worked for you from within a shockwave movie?
ASKER CERTIFIED SOLUTION
Avatar of ch2
ch2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
well i tried it again and it seemed to work. I appreciate your persistence.