• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to define outlook calendar to import to.

Hi,

I have a VBA code (that I got from a YouTube tutorial) that will upload dates in to an outlook calendar. This code uploads the info in to the default calendar but I would like for it to upload in to a new calendar that I have set up named "SL Work calendar". Also I plan to have an individual calendar for each staff member, each staff member would have their own list and I could put the name of their outlook calendar in cell A1 of their list worksheet. The code would then need to loop through each worksheet uploading the list in to each outlook calendar. How would I change the code so that it does this please?


This is the code:

>>> use code - tags <<<
Code:
Sub CreateAppointment()

    Set olOutlook = CreateObject("Outlook.Application")
    Set Namespace = olOutlook.GetNameSpace("MAPI")
    Set oloFolder = Namespace.GetDefaultFolder(9)
  
    LastRow = Cells(Rows.Count, 21).End(xlUp).Row
  
    For i = 3 To LastRow
  
        Description = Cells(i, 22).Value
        StartDate = Cells(i, 21).Value
      
        Set Appointment = oloFolder.items.Add
      
        With Appointment
        .Start = StartDate
        .Subject = Description
        .Save
      
        End With
  
    Next i



End Sub

I would also like for this to automatically run whenever the workbook is saved, how would I do this?
 

Attachments

  • Outlook Calendar worksheet.xlsm
    269 KB · Views: 0
Last edited by a moderator:
Back
Top