Project to Outlook

crackwood01

New Member
Joined
Mar 16, 2016
Messages
43
Hi everyone,

i wrote a vba code to export Microsoft project tasks as Outlook Calendar Appointments
VBA Code:
Sub ExportToOutlook()
Dim ol As Outlook.Application
Dim olAp As Outlook.AppointmentItem
Dim proj As Project
Dim t As Task
Dim pj As Project
Set pj = ActiveProject
For Each t In pj.Tasks
Set ol = New Outlook.Application
Set olAp = ol.CreateItem(olAppointmentItem)

With olAp
    .Subject = t.Name
    .Start = t.Start
    .End = t.Finish
    .Save
    End With
Next t

End Sub

For my needs, it's enough .. but i would like to create a userform to select the destination calendar from a userform combobox

With this code found here i'm able to pull a complete list of calendars, but how can i populate a combobox with it??

Code:
Sub IterateAllCalendars()
    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

    s = ""
    Set objOL = 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
        For Each objNavFolder In objNavGroup.NavigationFolders
            On Error Resume Next
            Set objFolder = objNavFolder.Folder
            If Err = 0 Then
                s = s & objNavGroup.Name & " -- " & objNavFolder.DisplayName & vbCrLf
            Else
                s = s & objNavGroup.Name & " -- " & objNavFolder.DisplayName & vbCrLf
            End If
            On Error GoTo 0
        Next
    Next
    Set objOL = Nothing
    Set objNS = Nothing
    Set objNavMod = Nothing
    Set objNavGroup = Nothing
    Set objNavFolder = Nothing
    Set objFolder = Nothing
    Set colExpl = Nothing
    MsgBox s
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,214,656
Messages
6,120,762
Members
448,991
Latest member
Hanakoro

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