T
ttempl
My vb.net app currently has a button for Outlook Contacts that sets focus to
Outlook, specifically the Contacts tab. Can I programmatically set focus to a
specific address book on the Contacts tab? I know I could physically set each
workstation using the "Show this address book first". But, the users could
change that. So, can I set focus to the correct address book from my app?
For example, my company has a global address list with all employees in it,
and I want to set focus to that address book instead of the user's personal
address book.
Current code
Dim olApp As Outlook.Application
Dim oNS As Outlook.NameSpace
olApp = CreateObject("Outlook.Application")
oNS = olApp.GetNamespace("MAPI")
If olApp.ActiveWindow Is Nothing Then
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Display()
Else
oNS.Application.ActiveExplorer.CurrentFolder =
oNS.Application.ActiveExplorer.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
End If
oNS.Application.ActiveExplorer.WindowState =
Outlook.OlWindowState.olNormalWindow
oNS.Application.ActiveExplorer.Left = 215
oNS.Application.ActiveExplorer.Top = 87
oNS.Application.ActiveExplorer.Width = 800
oNS.Application.ActiveExplorer.Height = 627
oNS.Application.ActiveExplorer.Activate()
olApp = Nothing
Outlook, specifically the Contacts tab. Can I programmatically set focus to a
specific address book on the Contacts tab? I know I could physically set each
workstation using the "Show this address book first". But, the users could
change that. So, can I set focus to the correct address book from my app?
For example, my company has a global address list with all employees in it,
and I want to set focus to that address book instead of the user's personal
address book.
Current code
Dim olApp As Outlook.Application
Dim oNS As Outlook.NameSpace
olApp = CreateObject("Outlook.Application")
oNS = olApp.GetNamespace("MAPI")
If olApp.ActiveWindow Is Nothing Then
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Display()
Else
oNS.Application.ActiveExplorer.CurrentFolder =
oNS.Application.ActiveExplorer.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
End If
oNS.Application.ActiveExplorer.WindowState =
Outlook.OlWindowState.olNormalWindow
oNS.Application.ActiveExplorer.Left = 215
oNS.Application.ActiveExplorer.Top = 87
oNS.Application.ActiveExplorer.Width = 800
oNS.Application.ActiveExplorer.Height = 627
oNS.Application.ActiveExplorer.Activate()
olApp = Nothing