Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Creating Outlook contacts in Word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roderick O'Regan - 23 Nov 2005 22:10 GMT
I have created a template in Word which works in all versions starting
from 2000.

There is a userform with a combobox which retrieves the company names
of people located in my Contacts folder in Outlook. This allows the
user to select a company which then puts the full address on paper
when the OK button is clicked.

All of this works OK.

However, what I would like to do is create another user form in Word
to allow operators to create a new Contact and then send it to the
default Outlook Contacts folder. All this without having to go into
Outlook, etc, etc.

I've managed to get some great help from the various sources on the
internet on how to GET names from Outlook using all the appropriate
field names and so on.

What I cannot puzzle out is how to PUT them into Outlook from Word
using VBA.

I'm sure I've seen this procedure set out somewhere recently whilst
trawling through the various newsgroups but it's a bit like a taxi in
wet weather: when you want one they can never be found!

Can anyone nudge me in the right direction, please?

Regards

Roderick O'Regan
Steve Yandl - 23 Nov 2005 23:25 GMT
Roderick,

Here is a small routine I created in an Excel userform that does roughly
what you want.  You will be pulling the values from Word rather than an
Excel worksheet but I think this will show you enough to set up your sub.
My subroutine is supposed to create a whole set of new contacts, not just
one.

Note that olApp was declared as a public variable and set as New
Outlook.Application outside this subroutine.

Private Sub CommandButton3_Click()

Dim itemContact As Outlook.ContactItem
Dim S As Integer
Dim rngA As Excel.Range

Set rngA = Sheets("Sheet1").UsedRange

For S = 1 To rngA.Rows.Count
  If Sheets("Sheet1").Cells(S, 3).Value = "NO" Then
  Set itemContact = olApp.CreateItem(olContactItem)
  With itemContact
     .FullName = Sheets("Sheet1").Cells(S, 1).Value
     .Email1Address = Sheets("Sheet1").Cells(S, 2).Value
     .Save
  End With
  End If
Next

End Sub

Steve
>I have created a template in Word which works in all versions starting
> from 2000.
[quoted text clipped - 27 lines]
>
> Roderick O'Regan
Roderick O'Regan - 24 Nov 2005 15:08 GMT
Thanks Steve for your helpful nudge.

Will get my head around this and let you know of the outcome.

Regards

Roderick

>Roderick,
>
[quoted text clipped - 60 lines]
>>
>> Roderick O'Regan
Doug Robbins - Word MVP - 24 Nov 2005 18:29 GMT
Note that to use Outlook objects as done in Steve's code, you will need to
set a reference to the Microsoft Outlook [version number] Object Library
under Tools>References in the Visual Basic Editor.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks Steve for your helpful nudge.
>
[quoted text clipped - 68 lines]
>>>
>>> Roderick O'Regan
Roderick O'Regan - 24 Nov 2005 21:51 GMT
Thanks Doug for the timely advice. I'd forgotten about that.

However, when I checked just now it was already set to Outlook 10.0
Object Library so I must have done it at some time.

Roderick

>Note that to use Outlook objects as done in Steve's code, you will need to
>set a reference to the Microsoft Outlook [version number] Object Library
>under Tools>References in the Visual Basic Editor.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.