If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Populate word using recordset data from asp page

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-26-04, 04:23
lindentree lindentree is offline
Registered User
 
Join Date: Nov 2004
Posts: 22
Question Populate word using recordset data from asp page

I am trying to populate a mailmerge word document from an asp page.
I need to pass data picked up from a recordset into a word template and then email the resulting merged word doc to the user. The user does not need to see the Word Document until picked up as the email attachment

I can get the email part to work with a blank word document attachment but
when I put in the following code
I keep getting the error:
Microsoft Word (0x800A1772)
Word could not fire the event.

It appears the problem lies with the path. As I am only running this locally on my pc at present the code path I have is:

set MyWord = createobject("Word.Application")
MyWord.Application.Documents.Open "D:\siteweb\projsummaries\EnvUtil.doc"
MyWord.ActiveWindow.Selection.GoTo -1,,, "ProjectTitle"
MyWord.ActiveWindow.Selection.TypeText cstr (Recordset1.Fields.Item("ProjectTitle").Value)
MyWord.ActiveWindow.Selection.GoTo -1,,, "Countries"
MyWord.ActiveWindow.Selection.TypeText cstr(Recordset1.Fields.Item("Countries").Value)
Path2File = "D:\siteweb\projsummaries\EnvUtil" &(Recordset1.Fields.Item("ProjectID").Value)& ".doc"
MyWord.ActiveDocument.SaveAs Path2File
set MyWord = Nothing

set objMail = Server.CreateObject ("CDO.Message")
objMail.AttachFile Path2File
objMail.To = (Recordset2.Fields.Item("email").Value)
objMail.From = "Intranet@plc.co.uk"
objMail.Subject = "Project Summary attached"
objMail.TextBody = "Project ID: "&(Recordset1.Fields.Item("ProjectID").Value)& ""
objMail.Send
set objMail = nothing

I haved searched Microsoft help to no avail!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On