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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning a linked Word document AND a page

Status
Not open for further replies.

Genimuse

Programmer
Joined
May 15, 2003
Messages
1,797
Location
US
So... I've got a form where the user selects some options and clicks a button. What I'd like to happen is that the form submits to itself (no prob), and upon returning it both redraws the form AND returns a... well, a Word document, sort of. Ideally the form would reappear in the browser window and Word would open the document at the address I sent back.

That is, I'm not trying to return a Word doc and an HTML form, but rather activate a link along the lines of \\ServerName\DirectoryName\File.doc and the HTML form, getting Word to open the file in question. I have no problem if IE insists on asking the user if they'd like to open or save it, if necessary, but I still want to effectively just send a link and have Word open it.

Does that make sense? Any idea on (a) how I return two things (I see it happen with "download" pages all the time, so I assume it's in the headers), and (b) how to send a link to be opened by Word, not the Word doc itself?
 
ok something like this...

Code:
<html>
<body>
<form>
'your form here
</form>
<%
if request.form("submit")<>"" then 'self referencing form
'show your search results in a table format or whatever format you want...lets say table format...

if rs.EOF AND rs.BOF then
response.write "sorry no records"
else
%>
<table>
<tr>
<th>link to word doc</th>
<th>Name of the doc</th>
<th>Description of the doc</th>
</tr>
do until rs.eof
%>
<tr>
<td><a href="#" onclick=viewdoc('<%=docid%>')>put word image here</a></td>
<td><%=rs("Name")%></td>
<td><%=rs("Description")%></td>
</tr>
</table>
<script language="vbscript">
sub viewdoc(docid)
window.open "[URL unfurl="true"]http://yourservername/&docid&.doc"[/URL]
end sub
</script>
</body>
</html>

okay i have just written the logic here without testing the code...i am sure there might be some mistakes with quotes and so on..so please test it...

-DNG
 
That's the idea, except for the parts I didn't make clear. ;-)

I know how to do the form submitting to itself and all that, but here's where I hit the problem.

What actually happens after the user submits the form is that I write out an Excel doc in the background, which is used as a source for a Word mail merge. Unfortunately if you open up a Word doc in a browser window, the mail merge tools are unavailable, so it has to be opened in Word itself. Because this is an intranet environment, I can point the user to "\\Server\Directory\document.doc" in a link and the Word doc will actually open up in Word, as opposed to an " which will open up as a Word doc inside the browser.

The page is designed to allow the user to select some criteria, and then hit a button to have Word open up with the appropriate document, ready to just hit the Merge button, AND the form is still sitting their with their old form criteria.

I can manage the form, and I know there's a way to return both an HTML document as well as a file (witness the many sites where you click a Download button for some application and it returns a pages saying "your download should start now" and then the download does), but I don't know how to do it.

In addition I don't know how to return not a file itself, but a pointer to a file on the server, along the lines of the "\\Server..." stuff.

Ideally there is no button or hyperlink that links to the document; rather, a button submits the criteria and the web server returns both the updated form and the Word doc, as separate items.

Does that make more sense?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top