Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Word Document

Status
Not open for further replies.

Jusenkyo

Programmer
Aug 16, 2002
295
GB
Hello all

I want to open a word document on the users PC (from the webserver) in an actionscript - when the user clicks a button...

What might the code be?

Cheers
Jusenkyo
 
Code:
on(release){
    getURL("[URL unfurl="true"]http://www.yoursite.com/your.doc",[/URL] "_blank");
}

Obviously replace the url and .doc by your's, and use "_self" rather than "_blank" if you don't want to open a new window, but open the .doc in the same window as the Flash movie itself.

Regards,

cubalibre2.gif
 
That doesn't seem to work...

The document I want to open up is on our file server (I am building an Intranet Site).
I wanted to just open that document, as well as a few spreadsheets, not in a web browser window (which is what the code oldnewbie gave me is trying to do) but just like it would if you double clicked on a shortcut!

I have tried a simple hyperlink, but it asks you if you want to download or open the file from its current location...

Is there any way that I can just get it to open straight away?

Cheers
 
I have some ASP code here that I think might open documents of any type not in a browser...

<%
'--------------------------------------------
Response.Buffer = True
Dim strFilePath, strFileSize, strFileName

Const adTypeBinary = 1

strFilePath = &quot;C:\ whatever the path is &quot;
strFileSize = ... the size of file .. optional
strFileName = the file na,e

Response.Clear

'8*******************************8
' Requires MDAC 2.5 to be stable
' I recommend MDAC 2.6 or 2.7
'8*******************************8
Set objStream = Server.CreateObject(&quot;ADODB.Stream&quot;)
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

strFileType = lcase(Right(strFileName, 4))

' Feel Free to Add Your Own Content-Types Here
Select Case strFileType
Case &quot;.asf&quot;
ContentType = &quot;video/x-ms-asf&quot;
Case &quot;.avi&quot;
ContentType = &quot;video/avi&quot;
Case &quot;.doc&quot;
ContentType = &quot;application/msword&quot;
Case &quot;.zip&quot;
ContentType = &quot;application/zip&quot;
Case &quot;.xls&quot;
ContentType = &quot;application/vnd.ms-excel&quot;
Case &quot;.gif&quot;
ContentType = &quot;image/gif&quot;
Case &quot;.jpg&quot;, &quot;jpeg&quot;
ContentType = &quot;image/jpeg&quot;
Case &quot;.wav&quot;
ContentType = &quot;audio/wav&quot;
Case &quot;.mp3&quot;
ContentType = &quot;audio/mpeg3&quot;
Case &quot;.mpg&quot;, &quot;mpeg&quot;
ContentType = &quot;video/mpeg&quot;
Case &quot;.rtf&quot;
ContentType = &quot;application/rtf&quot;
Case &quot;.htm&quot;, &quot;html&quot;
ContentType = &quot;text/html&quot;
Case &quot;.asp&quot;
ContentType = &quot;text/asp&quot;
Case Else
'Handle All Other Files
ContentType = &quot;application/octet-stream&quot;
End Select


Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment; filename= strFileName
Response.AddHeader &quot;Content-Length&quot;, strFileSize
' In a Perfect World, Your Client would also have UTF-8 as the default
' In Their Browser
Response.Charset = &quot;UTF-8&quot;
Response.ContentType = ContentType

Response.BinaryWrite objStream.Read
Response.Flush

objStream.Close
Set objStream = Nothing

%>


Any ideas where I need to put this in the code? I am not very good with ASP...
 
I'm no server side scripter myself at all... Suggest you look into fscommand and &quot;exec&quot;. Watch it new restrictions apply since MX, a fscommand subfolder among other things...

To open a specific file, you might also need to use a batch file (.bat)...

Otherwise, you acan have a look at this...


Or maybe 3rd party software as Flashjester, Flash Studio, or the free...


Regards,

cubalibre2.gif
 
Ahhhh, that looks like a good idea... I'll try the Flashgeek one...

The code to call an executable, I think, goes something like this:
filename = &quot;test.exe&quot;;
fscommand (&quot;exec&quot;, &quot;start\t&quot; + filename);
fscommand (&quot;exec&quot;, &quot;cmd\t/c\t&quot;+filename);

Where the text.exe is the program that I got from flashgeek... which opens the file location that I have specified (Works if you just double click it).

Does that look right?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top