populate body with Word data

  • Thread starter Thread starter J. Freed
  • Start date Start date
J

J. Freed

I have an Access DB with a field containing a Word doc as an embedded object.
I think I can retrieve the contents but I can't seem to figure out how to
populate them into the body of the message in VBA. I've seen a few postings
on this subject and I seem to be missing how to actually populate the body.
Any ideas? TIA.....
 
This is working well. Now, I need to be able to add data from tables/forms in
addition to the Word data. When I try to add to the body the Word data
disappears, so I'm guessing I need a way to add the data I want to the Word
doc before it gets posted to the note.

TIA.
 
I agree. Problem is, I have no idea how to do it. How would I take a field in
a form (or a table) and copy it into the Word doc generated by the code below:

Forms!fcp_new!wire.Verb = 0
Forms!fcp_new!wire.Action = 7
Forms!fcp_new!wire.Object.Application.ActiveDocument.Content.Select
Forms!fcp_new!wire.Object.Application.Selection.Range.Copy
Forms!fcp_new!wire.Action = 9
wd.ActiveDocument.SaveAs "L:\Operate1\ELPD_Middle_Office_Reports\OTC
Payments\eos.doc"
Set doc = wd.Documents.Open("L:\Operate1\ELPD_Middle_Office_Reports\OTC
Payments\eos.doc")
wd.Selection.Range.Paste
wd.ActiveDocument.SaveAs "L:\Operate1\ELPD_Middle_Office_Reports\OTC
Payments\eos.doc"
End If

which takes data from an OLE object in a table and copies it into a Word
doc, which then gets posted to the body using

Set itm = doc.MailEnvelope.Item

TIA......
 
Instead of wd.Selection.Range.Paste, you can use:

wd.Selection.Range.InsertAfter "some text"

or

wd.Selection.Range.InsertAfter some_string_variable_value

Also, the Word macro recorder can be your friend in these situations to show
the useful methods for a given scenario.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
That did the trick. Thanks again!

Sue Mosher said:
Instead of wd.Selection.Range.Paste, you can use:

wd.Selection.Range.InsertAfter "some text"

or

wd.Selection.Range.InsertAfter some_string_variable_value

Also, the Word macro recorder can be your friend in these situations to show
the useful methods for a given scenario.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Back
Top