A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to open Public Folders 'Contact Form' using VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 17th 06, 08:39 PM posted to microsoft.public.outlook.program_vba
mmattson
external usenet poster
 
Posts: 1
Default How to open Public Folders 'Contact Form' using VBA

I am using Access 2003, Outlook 2003, Exchange 2003

I am developing a simple Access CRM for our office. The DB uses a linked
connection to Outlook/Public Folders/Address Book to populate the contacts
table.

To create new contacts, it seems easiest to simply open a new contact form
to add the new contact. When I use the following code, it opens a new contact
form for my personal contacts folder. I need it to open a new contact form
for the Public Folders Address book. Here is the code I am using now:

Sub StartOutLook_click()
On Error GoTo StartOutLook_Error
Dim spObj As Object, MyItem As Object

' Create a Microsoft OutLook object.
Set spObj = CreateObject("Outlook.Application")

' Create and open new contact form for input.
Set MyItem = spObj.CreateItem(olContactItem)
MyItem.Display

' Quit Microsoft Outlook.
Set spObj = Nothing
Exit Sub

StartOutLook_Error:
MsgBox "Error: " & Err & " " & Error
Exit Sub
End Sub

**************************
I have also tried this code where I have gotten the ID for the Address Book
I want to use:
**************************

Private Sub PubFolderContact()
Dim olfolder As Outlook.mapiFolder
Dim olapp As Outlook.Application
Dim MyItem As Object
Set olapp = CreateObject("Outlook.Application")
Set olfolder = olapp.GetNamespace("Mapi").GetFolderFromID("000000
001A447390AA6611CD9BC800AA002FC45A030082A9113B53F5
E344B7226F2A7489F43100000009A8BD0000")
Set MyItem = olapp.CreateItem(olContactItem)
MyItem.Display

Set olfolder = Nothing
Set olapp = Nothing
End Sub

*****************

This code also only opens the Personal Contacts form. Please advise on how
to open a Public Folders/Address Book contact form.
  #2  
Old May 17th 06, 10:06 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default How to open Public Folders 'Contact Form' using VBA

To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection:

Set newItem = targetFolder.Items.Add("IPM.Post.YourFormName")

You can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"mmattson" wrote in message ...
I am using Access 2003, Outlook 2003, Exchange 2003

I am developing a simple Access CRM for our office. The DB uses a linked
connection to Outlook/Public Folders/Address Book to populate the contacts
table.

To create new contacts, it seems easiest to simply open a new contact form
to add the new contact. When I use the following code, it opens a new contact
form for my personal contacts folder. I need it to open a new contact form
for the Public Folders Address book. Here is the code I am using now:

Sub StartOutLook_click()
On Error GoTo StartOutLook_Error
Dim spObj As Object, MyItem As Object

' Create a Microsoft OutLook object.
Set spObj = CreateObject("Outlook.Application")

' Create and open new contact form for input.
Set MyItem = spObj.CreateItem(olContactItem)
MyItem.Display

' Quit Microsoft Outlook.
Set spObj = Nothing
Exit Sub

StartOutLook_Error:
MsgBox "Error: " & Err & " " & Error
Exit Sub
End Sub

**************************
I have also tried this code where I have gotten the ID for the Address Book
I want to use:
**************************

Private Sub PubFolderContact()
Dim olfolder As Outlook.mapiFolder
Dim olapp As Outlook.Application
Dim MyItem As Object
Set olapp = CreateObject("Outlook.Application")
Set olfolder = olapp.GetNamespace("Mapi").GetFolderFromID("000000
001A447390AA6611CD9BC800AA002FC45A030082A9113B53F5
E344B7226F2A7489F43100000009A8BD0000")
Set MyItem = olapp.CreateItem(olContactItem)
MyItem.Display

Set olfolder = Nothing
Set olapp = Nothing
End Sub

*****************

This code also only opens the Personal Contacts form. Please advise on how
to open a Public Folders/Address Book contact form.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What happens if multiple users update a contact stored in public folders? [email protected] Outlook - Using Forms 1 March 30th 06 03:18 PM
VBA shortcut to open custom form in design mode? Burma Jones Outlook and VBA 4 March 30th 06 11:37 AM
Too many Find Public Folders dialogs open JJSPROUT Outlook - Using Contacts 1 March 22nd 06 07:35 AM
Searching a contact folder created in Public Folders fails. Ben McKellar Outlook - Using Contacts 0 March 12th 06 10:26 PM
VBA shortcut to open custom form in design mode? Burma Jones Outlook - Using Forms 2 March 6th 06 07:17 PM


All times are GMT +1. The time now is 08:01 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-2025 Outlook Banter.
The comments are property of their posters.