?
Solved

Get list of shared calendars using VBA

Posted on 2013-11-06
4
Medium Priority
?
2,989 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 36

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 36

Accepted Solution

by:
Kimputer earned 1500 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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