Pull a list of Excel Calendars Name to Populate a Userform Combobox

crackwood01

New Member
Joined
Mar 16, 2016
Messages
43
***OUTLOOK CALENDARS

Hi

Here is my code so far, what am i missing?


VBA Code:
Sub Calendars(ByRef zCalendars() As String)
Dim s As String
    Dim objOL As Outlook.Application
    Dim objNS As Outlook.Namespace
    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
    Dim colExpl As Outlook.Explorers


 ReDim zCalendars(0)
 Dim lNb As Long

s = ""
Set objOL = Outlook.Application
    Set objNS = objOL.Session
    Set colExpl = objOL.Explorers
    Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
    Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)

      For Each objNavGroup In objNavMod.NavigationGroups
     
        ReDim Preserve zCalendars(lNb)
       
        On Error Resume Next
        Set objFolder = objNavFolder.Folder
        If Err = 0 Then
               
        zCalendars(lNb) = s & objNavFolder.DisplayName & vbCrLf
        lNb = lNb + 1
       
         Else
                zCalendars(lNb) = s & objNavFolder.DisplayName & vbCrLf
        lNb = lNb + 1
            End If
            On Error GoTo 0
        'olstrOutput = olstrOutput & olobjCategory.Name & vbCrLf
     Next

 'MsgBox olstrOutput
    Set objOL = Nothing
    Set objNS = Nothing
    Set objNavMod = Nothing
    Set objNavGroup = Nothing
    Set objNavFolder = Nothing
    Set objFolder = Nothing
    Set colExpl = Nothing
 End Sub

Private Sub UserForm_Initialize()
    Dim aCalendars() As String
    Dim i As Long

    Calendars aCalendars()

    Me.ComboBox1.List = aCalendars()

End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,215,396
Messages
6,124,685
Members
449,179
Latest member
kfhw720

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top