• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

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?
0
mikesandra
Asked:
mikesandra
  • 16
  • 12
  • 6
  • +1
1 Solution
 
CyanBlueCommented:
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
0
 
ch2Commented:
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');
?>
0
 
blockage1Commented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mikesandraAuthor Commented:
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?
0
 
ch2Commented:
Try this, change word.doc to your choice.

<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "content-disposition", "inline; filename = word.doc"
%>
0
 
mikesandraAuthor Commented:
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")      
}
0
 
ch2Commented:
This one should work.

<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment; filename = word.doc"
%>
0
 
mikesandraAuthor Commented:
Unfortunately, its trying to open up the hractive.asp file in dreamweaver still.
0
 
ch2Commented:
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
%>
0
 
blockage1Commented:
You need to run the asp file on a webserver and view it in a browser. You can't just click double click it.
0
 
ch2Commented:
But always make sure to use the correct path to the file.

Mike
0
 
mikesandraAuthor Commented:
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?
0
 
ch2Commented:
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.
0
 
mikesandraAuthor Commented:
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?
0
 
mikesandraAuthor Commented:
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.
0
 
ch2Commented:
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.
0
 
mikesandraAuthor Commented:
Can't I link from within my flash to an html page that automatically brings you to the asp page?
0
 
mikesandraAuthor Commented:
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.
0
 
blockage1Commented:
As I said before put it in a zip file
0
 
blockage1Commented:
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.
0
 
mikesandraAuthor Commented:
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.
0
 
mikesandraAuthor Commented:
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.
0
 
ch2Commented:
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>
0
 
blockage1Commented:
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.
0
 
mikesandraAuthor Commented:
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?
0
 
ch2Commented:
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.
0
 
mikesandraAuthor Commented:
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.
0
 
blockage1Commented:
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/
0
 
ch2Commented:
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.
0
 
mikesandraAuthor Commented:
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?
0
 
ch2Commented:
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.
0
 
mikesandraAuthor Commented:
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            
0
 
mikesandraAuthor Commented:
the asp worked for you from within a shockwave movie?
0
 
ch2Commented:
Yes it worked.

I start my browser then i go to this url http://localhost/myswf.swf and shows up a movie with a button, when pressed prompts the dialog asking to open or save.

Using iexplorer as the web browser.

// The code i used on my ASP file

<%
Dim objStream, myContents, myFileName

myFileName = "XmlNotepad.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
%>

// The code used on my fla.

on (press) {
      getURL("XmlNotepad.asp");
}
0
 
mikesandraAuthor Commented:
well i tried it again and it seemed to work. I appreciate your persistence.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 16
  • 12
  • 6
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now