I'm developing a VSTO Word Addin, and I'm tring to open a 'Global Adress List' in the MS Word (see bottom image).
Programatically I thought I could use the PickerDialog unfortunately i'm unable to open such a window.
The only way, I managed to open was using the Outlook Application:
//////////////////////// Outlook.Recipient theUser; Outlook.Application OLApp = (Outlook.Application) Helper.CreateObject("Outlook.Application"); //new Outlook.Application();// if (OLApp.ActiveWindow() != null) //only if there's a window OLApp.ActiveWindow().Activate(); //make sure outlook comes to foreground first else { // These 3 lines solved the problem Outlook.NameSpace ns = OLApp.GetNamespace("MAPI"); Outlook.MAPIFolder f = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); System.Threading.Thread.Sleep(5000); // test } Outlook.SelectNamesDialog OLDialog = OLApp.Session.GetSelectNamesDialog(); OLDialog.SetDefaultDisplayMode(Outlook.OlDefaultSelectNamesDisplayMode.olDefaultSingleName); if (OLDialog.Display()) { if (OLDialog.Recipients.Count > 0) { theUser = OLDialog.Recipients[1]; string name = theUser.Name; string email = theUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress; AddFormatedEmailTo(name, email); } }
This off course open an Outlook instance, and finally the Address Book Window.
Anybody knows any way to do this without using the Outlook.Application ?
Something like:
//http://social.msdn.microsoft.com/Forums/office/en-US/9b753040-72e2-4e11-bf31-63e1bd73e20c/pickerdialog-in-word-how-can-i-use-it-in-a-c-addin Microsoft.Office.Core.PickerDialog pd = ThisApplication.PickerDialog; pd.DataHandlerId = "{00020404-0000-0000-C000-000000000046}"; //HKEY_CLASSES_ROOT\MsoPeopleDataHandler.PeopleDataHandler\CLSID pd.Title = "Sample Picker Dialog"; pd.Show();
I appreciate your help.
Best Regards