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 doc in MSWord sometimes opens ASP script instead of results.

Status
Not open for further replies.

bcapps

Technical User
Jul 11, 2001
23
US
I have created a document in .asp using:

Code:
<% Response.ContenType = &quot;application/msword&quot; %>

at the top of my document and it works great for me and some of my users. The document accesses my database and creates a multipage document in WORD just as I expect it to. But when some of my users open the document, the page simply displays what my page looks like when I open it in MSFrontPage Preview mode, only in the browser as if they did not have WORD installed on their machine and the server was not executing any of my script.

Any Ideas on what may be causing this, I expect it may be something with the client machines, but I am completely clueless.

Thanks
bc
 
It's possible that it is in fact opening the Word document, only it's being opened inside the browser window without the full set of Word features.

You will be able to tell if this is the case, after the document is rendered inside the browser window, select File / Save As from the browser file menu. If it's prompting to save as Word Doc or RTF, then you're script is working fine.

There's a setting in the client operating system for each file type. In Win98 it's My Computer / View / Folder Options OR Options / File Types If you find the file type for .doc you'll notice an option to Open in Same Window. If this is checked on the client computer, Browsers will Open the appropriate software inside the browser window.

Now, Microsoft suggests getting Word documents to visitors a little differently. This won't really re-solve the problem you are having, but using this method, there is a workaround that I've seen many large reporting websites use.

Take a look at this article. You'll notice that here ASP is actually creating a Word document and saving that document on the web server. Then, you'll notice at the bottom of the sample code, that it writes a one line re-direct header to the browser which in effect navigates the browser to that document. Using this exact method, the document will still render inside the browser window if the visitor has the Open in Same Window checked for Word documents in their File Types settings. However, by having ASP create and save the document on the web server, what you can do is write an HTML page to the browser with an HREF link to the document. Then, below the link you can tell your visitors to Right Click and Save Target As or Save Link As to download the file onto their computer.


This is the method that large web reporting sites like GE Capital, BofA, and Paymentech are using for MS Word document reporting.

ToddWW
 
OK, yes it is actually trying to open the document on one of my users and making the changes you indicated did work. However, another of my users still has almost the same indications as before.

Now, while they are definitely opening the document in WORD and since I have a SUB at the top of my script that uses an IF statement to display one of three colors in various places throughout the document, all three of those colors are being displayed at the top of the word document as if they are downloading the code, not executing the server side script as they should be. Also none of the loops are running that would populate my reports as they should be.

I'm at a loss on this one.

Also, my application will be used on a corp intranet, and by only a select number of users, so I really don't want to redesign it again at this point. Thanks for the info on the link though. I may use that at another time.

Thanks
bc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top