473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

creating a document on the server (MS Word doc)

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 = "va***@ukonline.co.uk"
'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

Sep 4 '06 #1
2 6284

tamaker wrote:
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 = "va***@ukonline.co.uk"
'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
I assume there is more code than this in your file - I mean you have to
assign values to fname and lname. Have you got On error resume next
there too? Do you have Word installed on the machine on which you are
trying to create the document?

--
Mike Brind

Sep 5 '06 #2
Yes, the other facets (definition of variables, etc,) has exsisted for
years and works fine... I actually found out today that I was given the
wrong info and word does NOT exist on the server... so I ditched the
idea alltogether and am just sending out an HTML email message
dynamically to the registrants.

Thanks for the reply though.


Mike Brind wrote:
tamaker wrote:
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 = "va***@ukonline.co.uk"
'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

I assume there is more code than this in your file - I mean you have to
assign values to fname and lname. Have you got On error resume next
there too? Do you have Word installed on the machine on which you are
trying to create the document?

--
Mike Brind
Sep 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: nuve | last post by:
Hi Please help.. What I want to do is to create a web form that once submitted it takes the fields and opens a new instance of a Word Template and populates bookmarks within the document with the...
0
by: Bruce Zigenfous | last post by:
Hello, I am using an ASP that uses a third party active-x control to upload a file to a file server using the ADO Stream Object. It uses the FileSystemObject to create folders and files, which...
0
by: Bruce Zigenfous | last post by:
Hello, Here is the code. followed by an explanation for what I am trying to do. In particular, this line: BinaryStream.Write byteArray 'Need to format <%Response.Buffer=0 %> <!--#include...
3
by: m3ckon | last post by:
Hi there, I can succesfully create a word doc from my asp.net page, but I have 2 issues I need to resolve in order to use it in my app: 1) Creating a table: I seem unable to create a table,...
1
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
3
by: Chris Davoli | last post by:
I've got a requirement to build a page using MS WORD and then have the page show up on a web site. I know I can do a binary write and open up the WORD document in IE plugin. Don't really want to do...
5
by: darnnews | last post by:
Hi, I have been creating a database to keep track of press clippings, but I have hit a couple stumbling blocks. Any help is much appreciate. 1) Seeing if my query is done I have the...
0
by: dotNetDummi | last post by:
Hi experts, I have a task to print some data into a word document .I need to set the word document to readOnly. It's working but user still can edit. Is there any thing I can do whereby user...
5
by: Nitin Mahajan | last post by:
Guys Is there a way in C# to create a word object directly from a memory stream without passing that to hard disk (file stream). I think it doesn't makes sense to create a file just to read it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.