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

ASP form saving to WordDoc or similar 1

Status
Not open for further replies.

Seecke

IS-IT--Management
Aug 23, 2003
68
US
I am looking for some samples of code that allows a web form to save (dynamically named from data in the form) the collected data to the server in a word document (or similar) then sends an email letting a person know that the document is ready to download or view via the web. A database in not an option.

Any Ideas?

Thanks in advance to all who read and especially to all who reply!

Steven E. ncw
 
With the FileSystem object you can check if a file exists
Code:
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("output.txt"))=true Then
      Response.Write("exists.")
Else
      Response.Write("does not exist.")
End If

set fs=nothing
%>

With the same FileSystem object you can create a file and write content into it:
Code:
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject") 
set f=fs.CreateTextFile("output.txt",true)
f.write("Hello ")
f.write( request.form("name") )
f.close
set f=nothing
set fs=nothing
%>

Creating a Word document is possible if MS Office is installed on the web-server. I never create Word document, i like RTF format (Word can read that). Classic approach: write the RTF document with a RTF editor like Jarte, so you know what output to program. (RTF is ASCII).
Alternative: write output in HTML (Word >2K can read that too)
Yes you can send email with ASP, but it depends on server configuration. Look for CDONTS in this forum/ faq's. I never use CDONTS; i installed a free component on my server (ASPEmail) but you probably can not do that.
BTW: when the users enters information in a form and submit the form, you probably create the file within split seconds, so why an email? After the submit you directly redirect the user to a page with "Thanx for your input bla bla bla and here is the link:" . . . .


ttmug.gif
 
Use Foxbox ideea but the file name change to output.doc even if you write an text.
When you open it MSWord would automaticaly convert to a normal document.

________
George, M
 
oke, that's true, but when you want/need some formating (bold/ larger font) your lost with plain vanilla ASCII.
An HTML-formated text with .doc extention will work, but for better results use RTF.

ttmug.gif
 
The reason for the email is because the form is entered by the user which contains sensative information. Once completed and submit is pressed, there needs to be a way to contact our office to let the proper department know that there is information available to view. I currently use ASPMail for the email functionality and several forms already utilize this component

As for the output to a Word Doc, I would like to use our current form for displaying that information. (I am trying NOT to upset the brains of the departments that will be viewing the info.) No one should EVER view the file on their browser so having word on the server shouldn't be necessary (I Hope).

Thank you foxbox for the code sample! I will try and use it to its fullest!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top