Solved

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

Posted on 2006-11-24
35
731 Views
Last Modified: 2008-02-01
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
Comment
Question by:mikesandra
  • 16
  • 12
  • 6
  • +1
35 Comments
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 
LVL 5

Expert Comment

by:blockage1
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
Try this, change word.doc to your choice.

<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "content-disposition", "inline; filename = word.doc"
%>
0
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
This one should work.

<%
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment; filename = word.doc"
%>
0
 

Author Comment

by:mikesandra
Comment Utility
Unfortunately, its trying to open up the hractive.asp file in dreamweaver still.
0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 
LVL 5

Expert Comment

by:blockage1
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
But always make sure to use the correct path to the file.

Mike
0
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
Can't I link from within my flash to an html page that automatically brings you to the asp page?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 5

Expert Comment

by:blockage1
Comment Utility
As I said before put it in a zip file
0
 
LVL 5

Expert Comment

by:blockage1
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 
LVL 5

Expert Comment

by:blockage1
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 5

Expert Comment

by:blockage1
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
the asp worked for you from within a shockwave movie?
0
 
LVL 11

Accepted Solution

by:
ch2 earned 500 total points
Comment Utility
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
 

Author Comment

by:mikesandra
Comment Utility
well i tried it again and it seemed to work. I appreciate your persistence.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now