Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Insert records into outlook from Excel. (http://www.outlookbanter.com/outlook-vba/58290-insert-records-into-outlook-excel.html)

Edward October 4th 07 10:22 PM

Insert records into outlook from Excel.
 
Hi Everybody,
I have an Excel file with several hundred records as follow
A B
Name Project
Bob a
Bob b
John c
John d
John e
Mike f
. .
As you can see there might be several projects for each person (1 to 30) ,
also I have a standard letter in outlook that I want to email it to each
person and include all the projects he/she has. I want to use use VBA code to
achive this task any help greatly appriciated .
Note: I can't use mail merge because I don't want to send several emails to
each person when they have more than one project .
I'm mainly looking for the code to read excel from outlook also insert those
data in the body text of outlook in a proper paragraph.
--
Best regards,
Harvey

Michael Bauer [MVP - Outlook] October 5th 07 05:29 AM

Insert records into outlook from Excel.
 


From Outlook, please add a reference to Excel to your VBA project via
Tools/References. Then you can see Excel's object model in the object
browser (f2) as well.

To open a workbook see Excel.Application.Workbooks.Open. You can access a
single cell with the Range object and move to the next cell with the Offset
function.

Please open the Excel VBA help and see samples for the mentioned methods.

There's different ways to add text to an e-mail template. Easiest approach
might be using placeholders in the e-mail. E.g.: "... interesting text #1
and more..."

Then you can use the replace function to replace #1 by anythign else:

Item.Body = Replace(Item.Body, "#1", "anything else")


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Thu, 4 Oct 2007 14:22:02 -0700 schrieb Edward:

Hi Everybody,
I have an Excel file with several hundred records as follow
A B
Name Project
Bob a
Bob b
John c
John d
John e
Mike f
. .
As you can see there might be several projects for each person (1 to 30) ,
also I have a standard letter in outlook that I want to email it to each
person and include all the projects he/she has. I want to use use VBA code

to
achive this task any help greatly appriciated .
Note: I can't use mail merge because I don't want to send several emails

to
each person when they have more than one project .
I'm mainly looking for the code to read excel from outlook also insert

those
data in the body text of outlook in a proper paragraph.


Edward October 5th 07 09:28 PM

Insert records into outlook from Excel.
 
Thanks Michael, My specific question now is : In word when we want to insert
a text after the third paragraph we can write:
Activedocument.paragrphs(3).range.insertafter "text"
what is the equivalent code in Outlook . I think placeholders are not a good
option because the text i want to insert varies between 1 to 30 paragraphs(
project names inserting line after line). Any thoughts?
--
Best regards,
Edward


"Michael Bauer [MVP - Outlook]" wrote:



From Outlook, please add a reference to Excel to your VBA project via
Tools/References. Then you can see Excel's object model in the object
browser (f2) as well.

To open a workbook see Excel.Application.Workbooks.Open. You can access a
single cell with the Range object and move to the next cell with the Offset
function.

Please open the Excel VBA help and see samples for the mentioned methods.

There's different ways to add text to an e-mail template. Easiest approach
might be using placeholders in the e-mail. E.g.: "... interesting text #1
and more..."

Then you can use the replace function to replace #1 by anythign else:

Item.Body = Replace(Item.Body, "#1", "anything else")


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Thu, 4 Oct 2007 14:22:02 -0700 schrieb Edward:

Hi Everybody,
I have an Excel file with several hundred records as follow
A B
Name Project
Bob a
Bob b
John c
John d
John e
Mike f
. .
As you can see there might be several projects for each person (1 to 30) ,
also I have a standard letter in outlook that I want to email it to each
person and include all the projects he/she has. I want to use use VBA code

to
achive this task any help greatly appriciated .
Note: I can't use mail merge because I don't want to send several emails

to
each person when they have more than one project .
I'm mainly looking for the code to read excel from outlook also insert

those
data in the body text of outlook in a proper paragraph.



Michael Bauer [MVP - Outlook] October 6th 07 01:26 PM

Insert records into outlook from Excel.
 


As you already know Word's object model you might want to use that. Simply
ensure that Word is being used as mail editor (Outlook options), and then
the Word.Document object is available through the Inspector.WordEditor
property.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Fri, 5 Oct 2007 13:28:00 -0700 schrieb Edward:

Thanks Michael, My specific question now is : In word when we want to

insert
a text after the third paragraph we can write:
Activedocument.paragrphs(3).range.insertafter "text"
what is the equivalent code in Outlook . I think placeholders are not a

good
option because the text i want to insert varies between 1 to 30

paragraphs(
project names inserting line after line). Any thoughts?


Edward October 9th 07 08:19 PM

Insert records into outlook from Excel.
 
Thanks Michael , acctually I'm calling Outlook from word for sending the
documnets
and it works fine. Now I'm looking for a way to open Outlook contacts email
address list in word. Now I have to type the email address in a text box
inorder to use it in the code for sending the email to a proper person but i
want to know if there is a way to open Outlook email address dialogbox in
word?
--
Best regards,
Edward


"Michael Bauer [MVP - Outlook]" wrote:



As you already know Word's object model you might want to use that. Simply
ensure that Word is being used as mail editor (Outlook options), and then
the Word.Document object is available through the Inspector.WordEditor
property.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Fri, 5 Oct 2007 13:28:00 -0700 schrieb Edward:

Thanks Michael, My specific question now is : In word when we want to

insert
a text after the third paragraph we can write:
Activedocument.paragrphs(3).range.insertafter "text"
what is the equivalent code in Outlook . I think placeholders are not a

good
option because the text i want to insert varies between 1 to 30

paragraphs(
project names inserting line after line). Any thoughts?



Michael Bauer [MVP - Outlook] October 10th 07 05:58 AM

Insert records into outlook from Excel.
 


In OL07 there's the GetSelectNamesDialog function, which returns the
SelectNamesDialog object. Please see the object browser (f2) for details.

Prior to OL07 you would have to add the CDO 1.21 Library to your project and
call the AddressBook function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Tue, 9 Oct 2007 12:19:01 -0700 schrieb Edward:

Thanks Michael , acctually I'm calling Outlook from word for sending the
documnets
and it works fine. Now I'm looking for a way to open Outlook contacts

email
address list in word. Now I have to type the email address in a text box
inorder to use it in the code for sending the email to a proper person but

i
want to know if there is a way to open Outlook email address dialogbox in
word?


Edward October 11th 07 11:38 PM

Insert records into outlook from Excel.
 
Thanks Michael again ! I coudn't find the CDO 1.21 library to add as a
refrence but I used a different trick , I display the outlook mailitem with
all the data inserted from word into it and now user can user outlooks
address book and use its send button to send the email.
Thanks a lot for you time.
--
Best regards,
Edward


"Michael Bauer [MVP - Outlook]" wrote:



In OL07 there's the GetSelectNamesDialog function, which returns the
SelectNamesDialog object. Please see the object browser (f2) for details.

Prior to OL07 you would have to add the CDO 1.21 Library to your project and
call the AddressBook function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Tue, 9 Oct 2007 12:19:01 -0700 schrieb Edward:

Thanks Michael , acctually I'm calling Outlook from word for sending the
documnets
and it works fine. Now I'm looking for a way to open Outlook contacts

email
address list in word. Now I have to type the email address in a text box
inorder to use it in the code for sending the email to a proper person but

i
want to know if there is a way to open Outlook email address dialogbox in
word?




All times are GMT +1. The time now is 03:35 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com