Solved

Get list of shared calendars using VBA

Posted on 2013-11-06
4
2,284 Views
Last Modified: 2016-02-11
I'm writing a MS-Access application which needs to import calender appointments stored in Outlook/Exchange. I'm using the outlook object and so far I am able to import my "own" appointments.

But I would like to loop over all shared calendars in my outlook and therefore I need to know the calendernames. Any suggestions how to get this "list" would be appreciated
0
Comment
Question by:HugoMuller
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 39628966
Actually, I would loop through the whole Global Address List, if the organization isn't thousands of people.
	Set GAL = myNameSpace.AddressLists("Global Address List")
	Set allGAL = GAL.AddressEntries

For i = 1 To allGAL.Count
		Set entry = allGAL.Item(i)

etc....

Open in new window


put the GetSharedDefaultFolder codevin an exception, and it will skip the ones you have no access to.
0
 

Author Comment

by:HugoMuller
ID: 39629767
Thanks for your reply.
Your solution works like a charm. This is what I made of it:
Set GAL = olNameSpace.AddressLists("Global Address List")
    Set allGAL = GAL.AddressEntries

    For i = 1 To allGAL.Count
        Set entry = allGAL.Item(i)
        On Error Resume Next
        Set calUser = olNameSpace.CreateRecipient(entry)
        Set olFolder = olNameSpace.GetSharedDefaultFolder(calUser, olFolderCalendar)
        
        'Test whether folder is a Calendar folder
        If olFolder.DefaultItemType <> olAppointmentItem Then
            Debug.Print entry & " is not accessable"
        Else
            Debug.Print entry & " is accessable"
        End If
        
    Next

Open in new window


However, this will give me list with all accessible calenders but I would like to have only the Calendars that are configured in my Outlook.

Any ideas ?
0
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 39629811
OK, I figured you would have configured your Outlook already with only the calendars you have access to, but I guess you actually have access to a lot of calendars you don't even want to look at.

In that case, I would debug.print all calUsers, then remove that line, and from the results, pick only the users you want, and put in an

if (calUser = user1) or (calUser = user2) or (calUser = user3) or (calUser = user4) then
    extra code of the operations you want to perform on those calendars
end if
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40646857
Here's how to list all the shared calendars you have access to.  this is a modified version of some sample code from Sue Mosher's book "Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators".

Sub ListSharedCalendars()
    Dim objExpCal As Outlook.Explorer
    Dim objNavMod As Outlook.CalendarModule
    Dim objNavGroup As Outlook.NavigationGroup
    Dim objNavFolder As Outlook.NavigationFolder
    Dim objFolder As Outlook.Folder
    Set objExpCal = Session.GetDefaultFolder(olFolderCalendar).GetExplorer
    Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
    Set objNavGroup = objNavMod.NavigationGroups.GetDefaultNavigationGroup(olPeopleFoldersGroup)
    For Each objNavFolder In objNavGroup.NavigationFolders
        Debug.Print objNavFolder.DisplayName
    Next
    Set objNavMod = Nothing
    Set objNavGroup = Nothing
    Set objNavFolder = Nothing
    Set objFolder = Nothing
End Sub

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Resolve DNS query failed errors for Exchange
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now