Help!

populate body with Word data

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  Not able to select new contact or distribution li..  
Author Message
J. Freed
External


Since: Dec 20, 2006
Posts: 9



PostPosted: Tue May 12, 2009 12:47 pm    Post subject: populate body with Word data
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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.....
Back to top
Sue Mosher [MVP]
External


Since: Mar 19, 2009
Posts: 41



PostPosted: Tue May 12, 2009 5:40 pm    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Once you have your Word.Document object, you can use the technique shown at
http://www.outlookcode.com/codedetail.aspx?id=1333.

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


"J. Freed" <JFreed.RemoveThis@discussions.microsoft.com> wrote in message
news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
>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.....
Back to top
J. Freed
External


Since: Dec 20, 2006
Posts: 9



PostPosted: Thu May 14, 2009 1:27 pm    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It worked. Thanks!

"Sue Mosher [MVP]" wrote:

> Once you have your Word.Document object, you can use the technique shown at
> http://www.outlookcode.com/codedetail.aspx?id=1333.
>
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook 2007 Programming:
> Jumpstart for Power Users and Administrators
> http://www.outlookcode.com/article.aspx?id=54
>
>
> "J. Freed" <JFreed.DeleteThis@discussions.microsoft.com> wrote in message
> news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
> >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.....
>
>
>
Back to top
J. Freed
External


Since: Dec 20, 2006
Posts: 9



PostPosted: Fri Jun 12, 2009 7:41 am    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

"J. Freed" wrote:

> It worked. Thanks!
>
> "Sue Mosher [MVP]" wrote:
>
> > Once you have your Word.Document object, you can use the technique shown at
> > http://www.outlookcode.com/codedetail.aspx?id=1333.
> >
> > --
> > Sue Mosher, Outlook MVP
> > Author of Microsoft Outlook 2007 Programming:
> > Jumpstart for Power Users and Administrators
> > http://www.outlookcode.com/article.aspx?id=54
> >
> >
> > "J. Freed" <JFreed.TakeThisOut@discussions.microsoft.com> wrote in message
> > news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
> > >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.....
> >
> >
> >
Back to top
Sue Mosher [MVP]
External


Since: Mar 19, 2009
Posts: 41



PostPosted: Sat Jun 13, 2009 2:14 pm    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

That's probably the best way to do it, to preserve formatting, etc.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"J. Freed" <JFreed DeleteThis @discussions.microsoft.com> wrote in message
news:13AB3DE1-D63A-4535-A4BA-3D56152F36AC@microsoft.com...
> 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.
>
> "J. Freed" wrote:
>
>> It worked. Thanks!
>>
>> "Sue Mosher [MVP]" wrote:
>>
>> > Once you have your Word.Document object, you can use the technique
>> > shown at
>> > http://www.outlookcode.com/codedetail.aspx?id=1333.

>> >
>> > "J. Freed" <JFreed DeleteThis @discussions.microsoft.com> wrote in message
>> > news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
>> > >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.....
>> >
>> >
>> >
Back to top
J. Freed
External


Since: Dec 20, 2006
Posts: 9



PostPosted: Mon Jun 15, 2009 12:46 pm    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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......

"Sue Mosher [MVP]" wrote:

> That's probably the best way to do it, to preserve formatting, etc.
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook 2007 Programming:
> Jumpstart for Power Users and Administrators
> http://www.outlookcode.com/article.aspx?id=54
>
>
> "J. Freed" <JFreed.RemoveThis@discussions.microsoft.com> wrote in message
> news:13AB3DE1-D63A-4535-A4BA-3D56152F36AC@microsoft.com...
> > 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.
> >
> > "J. Freed" wrote:
> >
> >> It worked. Thanks!
> >>
> >> "Sue Mosher [MVP]" wrote:
> >>
> >> > Once you have your Word.Document object, you can use the technique
> >> > shown at
> >> > http://www.outlookcode.com/codedetail.aspx?id=1333.
>
> >> >
> >> > "J. Freed" <JFreed.RemoveThis@discussions.microsoft.com> wrote in message
> >> > news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
> >> > >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.....
> >> >
> >> >
> >> >
>
>
>
Back to top
Sue Mosher [MVP]
External


Since: Mar 19, 2009
Posts: 41



PostPosted: Tue Jun 16, 2009 6:29 am    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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


"J. Freed" <JFreed.DeleteThis@discussions.microsoft.com> wrote in message
news:4657EFBE-B28D-48CC-8811-388FF2E6D2A8@microsoft.com...
>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......
>
> "Sue Mosher [MVP]" wrote:
>
>> That's probably the best way to do it, to preserve formatting, etc.
>> --
>> Sue Mosher, Outlook MVP
>> Author of Microsoft Outlook 2007 Programming:
>> Jumpstart for Power Users and Administrators
>> http://www.outlookcode.com/article.aspx?id=54
>>
>>
>> "J. Freed" <JFreed.DeleteThis@discussions.microsoft.com> wrote in message
>> news:13AB3DE1-D63A-4535-A4BA-3D56152F36AC@microsoft.com...
>> > 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.
>> >
>> > "J. Freed" wrote:
>> >
>> >> It worked. Thanks!
>> >>
>> >> "Sue Mosher [MVP]" wrote:
>> >>
>> >> > Once you have your Word.Document object, you can use the technique
>> >> > shown at
>> >> > http://www.outlookcode.com/codedetail.aspx?id=1333.
>>
>> >> >
>> >> > "J. Freed" <JFreed.DeleteThis@discussions.microsoft.com> wrote in message
>> >> > news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
>> >> > >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.....
>> >> >
>> >> >
>> >> >
>>
>>
>>
Back to top
J. Freed
External


Since: Dec 20, 2006
Posts: 9



PostPosted: Tue Jun 16, 2009 7:16 am    Post subject: Re: populate body with Word data [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

That did the trick. Thanks again!

"Sue Mosher [MVP]" wrote:

> 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
>
>
> "J. Freed" <JFreed RemoveThis @discussions.microsoft.com> wrote in message
> news:4657EFBE-B28D-48CC-8811-388FF2E6D2A8@microsoft.com...
> >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......
> >
> > "Sue Mosher [MVP]" wrote:
> >
> >> That's probably the best way to do it, to preserve formatting, etc.
> >> --
> >> Sue Mosher, Outlook MVP
> >> Author of Microsoft Outlook 2007 Programming:
> >> Jumpstart for Power Users and Administrators
> >> http://www.outlookcode.com/article.aspx?id=54
> >>
> >>
> >> "J. Freed" <JFreed RemoveThis @discussions.microsoft.com> wrote in message
> >> news:13AB3DE1-D63A-4535-A4BA-3D56152F36AC@microsoft.com...
> >> > 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.
> >> >
> >> > "J. Freed" wrote:
> >> >
> >> >> It worked. Thanks!
> >> >>
> >> >> "Sue Mosher [MVP]" wrote:
> >> >>
> >> >> > Once you have your Word.Document object, you can use the technique
> >> >> > shown at
> >> >> > http://www.outlookcode.com/codedetail.aspx?id=1333.
> >>
> >> >> >
> >> >> > "J. Freed" <JFreed RemoveThis @discussions.microsoft.com> wrote in message
> >> >> > news:D28BDE83-F73E-4E60-8605-7C1FE08B323D@microsoft.com...
> >> >> > >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.....
> >> >> >
> >> >> >
> >> >> >
> >>
> >>
> >>
>
>
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum