Outlook Import Addin

D

David Phelan

Is it Possible to write an Add-in for Outlook 2000 which can be added to
the import filter list?

I have written a piece of code to import an .ldif file into the Outlook
contact list. But I don't know how to add it to the import filter list.

Can anyone help?

TIA

Dave Phelan
Pitman
 
R

Randy Byrne [MVP - Outlook]

The Outlook Import/Export wizard is not extensible with an Outlook COM
Add-in. That being said, you can certainly add your own Command Bar
button(s) to launch your own application.

--
Randy Byrne, MVP - Outlook
http://www.microeye.com
Building Applications with Microsoft Outlook 2002 (MSPress - July 2001)
Building Applications with Microsoft Outlook 2000 (MSPress)
http://www.microeye.com/books
Micro Eye ZipOut
http://www.microeye.com/zipout
 
D

David Phelan

The Outlook Import/Export wizard is not extensible with an Outlook COM
Add-in. That being said, you can certainly add your own Command Bar
button(s) to launch your own application.

I have tried to apply your suggesion. The CommandBars collection is
certainly burried. I tested my code in the Outlook VBA editor and it
worked. I added the code to my project, created the AddIn, and installed
it. But when Outlook comes up and attempts to load the dll, it throws
error 483 Object Dosen't Support This Property or Method when trying to
add the command bar button.

The code to add the button is below:


Function CreateAddInCommandBarButton(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object) As Office.CommandBarButton

Dim objOtlk As Outlook.Application
Dim cbrMenu As Office.CommandBarControl
Dim ctlBtnAddIn As Office.CommandBarButton
Dim objExp As Outlook.Explorer
On Error GoTo CreateAddInCommandBarButton_Err

Set gobjAppInstance = Application
'Set objOtlk = GetObject(, "outlook.application")

For Each objExp In gobjAppInstance 'objOtlk
If objExp.Caption = "Inbox - Microsoft Outlook" Then
' Return reference to command bar.
Set cbrMenu = objExp.CommandBars("Menu Bar")

' Add button to call add-in from command bar, if it doesn't
' already exist.
' Constants are declared at module level.
' Look for button on command bar.
Set ctlBtnAddIn = cbrMenu.FindControl(Tag:=CTL_KEY)
If ctlBtnAddIn Is Nothing Then
' Add new button.
Set ctlBtnAddIn = cbrMenu.Controls.Add(Type:
=msoControlButton, _
Parameter:=CTL_KEY)
' Set button's Caption, Tag, Style, and OnAction
properties.
With ctlBtnAddIn
.Caption = CTL_CAPTION
.Tag = CTL_KEY
.Style = msoButtonCaption
' Use AddInInst argument to return reference
' to this add-in.
.OnAction = PROG_ID_START & AddInInst.ProgId _
& PROG_ID_END
End With
End If
Exit For
End If
Next objExp

' Return reference to new commandbar button.
Set CreateAddInCommandBarButton = ctlBtnAddIn

CreateAddInCommandBarButton_End:
Set ctlBtnAddIn = Nothing
Set cbrMenu = Nothing
Set objExp = Nothing
Set objOtlk = Nothing
Set gobjAppInstance = Nothing
Exit Function

CreateAddInCommandBarButton_Err:
' Call generic error handler for add-in.
AddInErr err
Resume CreateAddInCommandBarButton_End
End Function


As you can see, I have also tried getting to Outlook application to add
the command bar to no avail. The core functionality works in the VBA
editor as I said. I don't know what to look for and I havent found a way
to step throught the code in debug mode to find the exact point of
failure. If I could even do that I could probably fix it.

Can anyone see a problem in the code? Any help is appreciated.

TIA

Dave Phelan
Pitman
 
D

David Phelan

Made a change but still does not work.
I have tried to apply your suggesion. The CommandBars collection is
certainly burried. I tested my code in the Outlook VBA editor and it
worked. I added the code to my project, created the AddIn, and installed
it. But when Outlook comes up and attempts to load the dll, it throws
error 483 Object Dosen't Support This Property or Method when trying to
add the command bar button.

The code to add the button is below:


Function CreateAddInCommandBarButton(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object) As Office.CommandBarButton

Dim objOtlk As Outlook.Application

Dim cbrMenu As Office.CommandBarControl

Cnanged this to CommandBar as it should be
 
D

David Phelan

Take a look at the Items Command Bar sample at
http://www.microeye.com/resources

It should help you fix your Command Bar code.

OK, I fixed that problem. Now I would like to be able to give the user
the ability to choose which contact list to add the new items to with the
ability to create new folders. I can choose the folder when it has
already been created, but I can't seem to create a new one. Code below:


Public Function GetContactLists(objOutlook As Outlook.Application,
Optional ListName As String) As Variant

Dim nspUser As NameSpace
Dim lstAddress As AddressList
Dim arList() As String
Dim I As Integer

Set nspUser = objOutlook.GetNamespace("MAPI")

If IsMissing(ListName) Then
For Each lstAddress In nspUser.AddressLists
ReDim Preserve arList(I)
arList(I) = lstAddress.Name
I = I + 1
GetContactLists = arList
Next lstAddress
Else
On Error Resume Next
Set lstAddress = nspUser.AddressLists.Item(ListName)
If lstAddress Is Nothing Then
Set lstAddress = nspUser.Folders.Add(ListName, olFolderContacts)
<--- Errors on this line --->
End If
GetContactLists = lstAddress
End If

Set lstAddress = Nothing
Set NameSpace = Nothing
Set objOutlook = Nothing
Set nspUser = Nothing


End Function

TIA

Dave Phelan
Pitman
 
R

Randy Byrne [MVP - Outlook]

lstAddress is Dim'ed as Outlook.AddressList. When you call Set lstAddress =
nspUser.Folders.Add(ListName, olFolderContacts), this function returns an
Outlook.MAPIFolder object rather than an Outlook.AddressList and the marked
line below returns a Type Mismatch error and fails to create the object.

--
Randy Byrne, MVP - Outlook
http://www.microeye.com
Building Applications with Microsoft Outlook 2002 (MSPress - July 2001)
Building Applications with Microsoft Outlook 2000 (MSPress)
http://www.microeye.com/books
Micro Eye ZipOut
http://www.microeye.com/zipout
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top