T
tamaker
I have a registration form where a user is able to, upon submission of
the form, have their submission entered into a simple database... now
Im looking to create a word document on the fly from that submission
using this as a model to build from:
http://www.freevbcode.com/ShowCode.Asp?ID=1727
There are no errors generated but there is NO .DOC file created at all
either... Im not sure what Im doing wrong... any clue what I need to
change to get this to work?
heres the code:
' CREATE WORD DOCUMENT
Set WordApp = CreateObject("word.application")
Set WordDoc = WordApp.Documents.Add()
WordApp.Application.Visible = False
Set MyRange1 = WordDoc.Paragraphs.Add.Range
MyRange1.InsertBefore("Appraisal Form")
MyRange1.Style = "Heading 1"
Set MyRange1 = WordDoc.Paragraphs.Add.Range
MyRange1.InsertBefore("Manager: " & fname & vbcrlf & "Appraisee: "
& lname)
MyRange1.Font.Bold = true
Set MyRange1 = WordDoc.Paragraphs.Add.Range
MyRange1.InsertBefore(vbcrlf & "Please fill in all the required
sections and return to HR via the internal mail system.")
' Set the directory location to store the generated documents
WordDocPath = Server.MapPath("")
' Use the unique session ID as the filename.
WordDoc.SaveAs WordDocPath & "" & session.sessionID & ".doc"
WordDoc.Close
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
' EMAIL WORD DOCUMENT
'Set mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
'recipient = Email
'sender = "(e-mail address removed)"
'subject = "Requested Form"
'message = "Please find the requested document attached."
'attach = WordDocPath & "\" & session.SessionID & ".doc"
'INSERT YOUR MAIL SERVER HERE
'mailserver = "xxx.xx.xx.xx"
'result = mailer.SMAttach(mailserver, recipient, sender, subject,
message, attach)
' DELETE WORD DOCUMENT FROM SERVER
'Set fso = CreateObject("Scripting.FileSystemObject")
'fso.DeleteFile(WordDocPath & "\" & session.SessionID & ".doc")
'Response.Write "The requested form will arrive in your inbox
(email) within a few minutes. Please complete and return to HR
asap."
'Response.Write "There has been an error sending the document to
you." & vbcrlf
'Response.Write "Right click the following link and select ""Save
Target As..."" to retrieve the word document." & vbcrlf & vbcrlf
Response.Write "<A href=""" & session.SessionID & ".doc"">Generated
Document</A>" & vbcrlf & vbcrlf
the form, have their submission entered into a simple database... now
Im looking to create a word document on the fly from that submission
using this as a model to build from:
http://www.freevbcode.com/ShowCode.Asp?ID=1727
There are no errors generated but there is NO .DOC file created at all
either... Im not sure what Im doing wrong... any clue what I need to
change to get this to work?
heres the code:
' CREATE WORD DOCUMENT
Set WordApp = CreateObject("word.application")
Set WordDoc = WordApp.Documents.Add()
WordApp.Application.Visible = False
Set MyRange1 = WordDoc.Paragraphs.Add.Range
MyRange1.InsertBefore("Appraisal Form")
MyRange1.Style = "Heading 1"
Set MyRange1 = WordDoc.Paragraphs.Add.Range
MyRange1.InsertBefore("Manager: " & fname & vbcrlf & "Appraisee: "
& lname)
MyRange1.Font.Bold = true
Set MyRange1 = WordDoc.Paragraphs.Add.Range
MyRange1.InsertBefore(vbcrlf & "Please fill in all the required
sections and return to HR via the internal mail system.")
' Set the directory location to store the generated documents
WordDocPath = Server.MapPath("")
' Use the unique session ID as the filename.
WordDoc.SaveAs WordDocPath & "" & session.sessionID & ".doc"
WordDoc.Close
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
' EMAIL WORD DOCUMENT
'Set mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
'recipient = Email
'sender = "(e-mail address removed)"
'subject = "Requested Form"
'message = "Please find the requested document attached."
'attach = WordDocPath & "\" & session.SessionID & ".doc"
'INSERT YOUR MAIL SERVER HERE
'mailserver = "xxx.xx.xx.xx"
'result = mailer.SMAttach(mailserver, recipient, sender, subject,
message, attach)
' DELETE WORD DOCUMENT FROM SERVER
'Set fso = CreateObject("Scripting.FileSystemObject")
'fso.DeleteFile(WordDocPath & "\" & session.SessionID & ".doc")
'Response.Write "The requested form will arrive in your inbox
(email) within a few minutes. Please complete and return to HR
asap."
'Response.Write "There has been an error sending the document to
you." & vbcrlf
'Response.Write "Right click the following link and select ""Save
Target As..."" to retrieve the word document." & vbcrlf & vbcrlf
Response.Write "<A href=""" & session.SessionID & ".doc"">Generated
Document</A>" & vbcrlf & vbcrlf