Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Upload from Excel to Outlook Calendar using VBA - Change colour

Posted on 2009-05-08
1
Medium Priority
?
489 Views
Last Modified: 2013-11-29
Hi all

I have some VBA code that I have taken from one of the forums that uploads a list of appointments from excel into MS Outlook Calendar, and played around with it to fit my needs.  However, In addition to the properties I have in the code below, I also want to add to colour to the appointment blocks showing in Outlook to distiguish different areas of the business.  Is this possible?  I tried adding 'Label' as a property in the 'appt' block below, but this was not recognised.

Also, is it possible to automate deletion of specified appointments if necessary

Thanks in advance
Sub ScheduleAppts()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appt As Outlook.AppointmentItem
Dim myRecipient As Outlook.Recipient
 
NumberofRecipients = Range("L3").Value
 
For i = 2 To NumberofRecipients
 
test = Environ("username")
 
Set ns = ol.GetNamespace("MAPI")
 
Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
Set myRecipient = ns.CreateRecipient(test)
myRecipient.Resolve
Set olFolder = ns.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
 
 
Set appt = olFolder.Items.Add
 
iDate = Range("A" & i & "").Value
oDate = Range("B" & i & "").Value + 1
 
With appt
        .Start = iDate
        .End = oDate
        .Subject = Range("C" & i & "").Value
        .BusyStatus = olBusy
        .AllDayEvent = True
        .ReminderMinutesBeforeStart = 120
        .ReminderSet = True
        .Save
        End With
 
Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
Next i
End Sub

Open in new window

0
Comment
Question by:TED_UBB
1 Comment
 
LVL 6

Accepted Solution

by:
Boris Petrovic earned 200 total points
ID: 24335168
Try this solution (all you have to do is adapt the code to call the functions from Excel): http://www.mrexcel.com/forum/showthread.php?t=79379
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

927 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