Import and export

  • Thread starter Thread starter Leho
  • Start date Start date
L

Leho

Is there any way to use "import and export" function with vba in
outlook? How? I need a little help not the total program.

Or I have to use it with "AddressLists" and "AddressEntries" somehow?

I want to do that before outlook starts up it updates it's contacts list
from certain excel file.

Excel.Workbooks.Open "c:\patch\to\my\excel\contacts\file.xls", ,
ReadOnly <== This works.

I think that I can access the ranges and values also, but the export and
imort is problematic. Is there need for "named ranges" in excel file?
 
Leho said:
Is there any way to use "import and export" function with vba in
outlook? How? I need a little help not the total program.

Or I have to use it with "AddressLists" and "AddressEntries" somehow?

I want to do that before outlook starts up it updates it's contacts list
from certain excel file.

Excel.Workbooks.Open "c:\patch\to\my\excel\contacts\file.xls", ,
ReadOnly <== This works.

I think that I can access the ranges and values also, but the export and
imort is problematic. Is there need for "named ranges" in excel file?

Now I did a little by myself:
I have a Folder "Contacts" and it there is a folder "Tarkon". So I
followed the help and did it this way:

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set ContactsFolder = _
myNameSpace.GetDefaultFolder(olFolderContacts)
Set TarkonFolder = ContactsFolder.Folders("Tarkon")

This works:
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Move (TarkonFolder)

These do not work:
TarkonFolder.CreateItem (olContactItem)
Outlook.Application.GetNamespace("MAPI").Folders(1).Folders("Contacts").Folders("Tarkon").CreateItem
(olContactItem)

Why?
 
To create an item in a specific folder, you need to use the MAPIFolder.Items.add method:

Set TarkonFolder = ContactsFolder.Folders("Tarkon")
Set myItem = TarkonFolder.Items.Add

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top