Solved

Get list of shared calendars using VBA

Posted on 2013-11-06
4
2,544 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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