A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Appointment Label Color



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 30th 06, 08:06 PM posted to microsoft.public.outlook.program_vba
OscarM
external usenet poster
 
Posts: 8
Default Appointment Label Color

Hi,

I'm using the source code from
http://www.outlookcode.com/codedetail.aspx?id=139 along with CDO 1.21 to set
a calendar color label in Outlook.

It works from one pc, but it does not work from others. There are no errors.

Please help.

This is the code I'm using:

Dim objAppt As Outlook.AppointmentItem
Dim objFolder As MAPIFolder

' get Kaltron Calendar
Set objFolder = GetFolder("Public Folders/All Public Folders/Inbound
Water Transit")
' Set objFolder = GetFolder("Public Folders/Favorites/Inbound Water
Transit")

' create appointment on Kaltron Calendar
Set objAppt = objFolder.Items.Add("IPM.Appointment")

' set appointment properties
With objAppt
.Start = Me![EST SHIP DATE]
.Subject = "TEST PO #" & Me!PO & " " & Me!PRODUCT & " (" & Me![LOC
CODE] & ")"
.Body = "TEST PO #" & Me!PO & " " & Me!PRODUCT & " (" & Me![LOC CODE]
& ")"
.AllDayEvent = True
.Save

' set appointment label color based on LOC CODE
If Me![LOC CODE] = "KP" Then
Call SetApptColorLabel(objAppt, 3) 'green
ElseIf Me![LOC CODE] = "KUP" Then
Call SetApptColorLabel(objAppt, 2) 'blue
ElseIf Me![LOC CODE] = "DIRECT" Then
Call SetApptColorLabel(objAppt, 10) 'yellow
Else
Call SetApptColorLabel(objAppt, 1) 'red
End If

.Close (olSave)
End With



Sub SetApptColorLabel(objAppt1 As Outlook.AppointmentItem, _
intColor As Integer)
' requires reference to CDO 1.21 Library
' adapted from sample code by Randy Byrne
' intColor corresponds to the ordinal value of the color label
'1=Important, 2=Business, etc.
Const CdoPropSetID1 = "0220060000000000C000000000000046"
Const CdoAppt_Colors = "0x8214"
Dim objCDO As MAPI.Session
Dim objMsg As MAPI.MESSAGE
Dim colFields As MAPI.Fields
Dim objField As MAPI.Field
Dim strMsg As String
Dim intAns As Integer
On Error Resume Next

Set objCDO = CreateObject("MAPI.Session")
objCDO.Logon "", "", False, False
If Not objAppt1.EntryID = "" Then
Set objMsg = objCDO.GetMessage(objAppt1.EntryID, _
objAppt1.Parent.StoreID)
Set colFields = objMsg.Fields
Set objField = colFields.Item(CdoAppt_Colors, CdoPropSetID1)
If objField Is Nothing Then
Err.Clear
Set objField = colFields.Add(CdoAppt_Colors, vbLong, intColor,
CdoPropSetID1)
Else
objField.Value = intColor
End If
objMsg.Update True, True
Else
strMsg = "You must save the appointment before you add a color
label. " & _
"Do you want to save the appointment now?"
intAns = MsgBox(strMsg, vbYesNo + vbDefaultButton1, "Set Appointment
Color Label")
If intAns = vbYes Then
Call SetApptColorLabel(objAppt1, intColor)
Else
Exit Sub
End If
End If

Set objAppt1 = Nothing
Set objMsg = Nothing
Set colFields = Nothing
Set objField = Nothing
objCDO.Logoff
Set objCDO = Nothing
End Sub



Ads
  #2  
Old August 30th 06, 08:24 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Appointment Label Color

YOu won't see any errors until you comment out the On Error Resume Next statement.

Have you checked to see whether CDO is installed on this machine?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"OscarM" wrote in message ...
Hi,

I'm using the source code from
http://www.outlookcode.com/codedetail.aspx?id=139 along with CDO 1.21 to set
a calendar color label in Outlook.

It works from one pc, but it does not work from others. There are no errors.

Please help.

This is the code I'm using:

Dim objAppt As Outlook.AppointmentItem
Dim objFolder As MAPIFolder

' get Kaltron Calendar
Set objFolder = GetFolder("Public Folders/All Public Folders/Inbound
Water Transit")
' Set objFolder = GetFolder("Public Folders/Favorites/Inbound Water
Transit")

' create appointment on Kaltron Calendar
Set objAppt = objFolder.Items.Add("IPM.Appointment")

' set appointment properties
With objAppt
.Start = Me![EST SHIP DATE]
.Subject = "TEST PO #" & Me!PO & " " & Me!PRODUCT & " (" & Me![LOC
CODE] & ")"
.Body = "TEST PO #" & Me!PO & " " & Me!PRODUCT & " (" & Me![LOC CODE]
& ")"
.AllDayEvent = True
.Save

' set appointment label color based on LOC CODE
If Me![LOC CODE] = "KP" Then
Call SetApptColorLabel(objAppt, 3) 'green
ElseIf Me![LOC CODE] = "KUP" Then
Call SetApptColorLabel(objAppt, 2) 'blue
ElseIf Me![LOC CODE] = "DIRECT" Then
Call SetApptColorLabel(objAppt, 10) 'yellow
Else
Call SetApptColorLabel(objAppt, 1) 'red
End If

.Close (olSave)
End With



Sub SetApptColorLabel(objAppt1 As Outlook.AppointmentItem, _
intColor As Integer)
' requires reference to CDO 1.21 Library
' adapted from sample code by Randy Byrne
' intColor corresponds to the ordinal value of the color label
'1=Important, 2=Business, etc.
Const CdoPropSetID1 = "0220060000000000C000000000000046"
Const CdoAppt_Colors = "0x8214"
Dim objCDO As MAPI.Session
Dim objMsg As MAPI.MESSAGE
Dim colFields As MAPI.Fields
Dim objField As MAPI.Field
Dim strMsg As String
Dim intAns As Integer
On Error Resume Next

Set objCDO = CreateObject("MAPI.Session")
objCDO.Logon "", "", False, False
If Not objAppt1.EntryID = "" Then
Set objMsg = objCDO.GetMessage(objAppt1.EntryID, _
objAppt1.Parent.StoreID)
Set colFields = objMsg.Fields
Set objField = colFields.Item(CdoAppt_Colors, CdoPropSetID1)
If objField Is Nothing Then
Err.Clear
Set objField = colFields.Add(CdoAppt_Colors, vbLong, intColor,
CdoPropSetID1)
Else
objField.Value = intColor
End If
objMsg.Update True, True
Else
strMsg = "You must save the appointment before you add a color
label. " & _
"Do you want to save the appointment now?"
intAns = MsgBox(strMsg, vbYesNo + vbDefaultButton1, "Set Appointment
Color Label")
If intAns = vbYes Then
Call SetApptColorLabel(objAppt1, intColor)
Else
Exit Sub
End If
End If

Set objAppt1 = Nothing
Set objMsg = Nothing
Set colFields = Nothing
Set objField = Nothing
objCDO.Logoff
Set objCDO = Nothing
End Sub



  #3  
Old September 1st 06, 05:15 PM posted to microsoft.public.outlook.program_vba
OscarM
external usenet poster
 
Posts: 8
Default Appointment Label Color

It was not installed. That's why it was not working.

I just registered "cdo.dll" and it worked.


Thanks for your help!



"Sue Mosher [MVP-Outlook]" wrote:

YOu won't see any errors until you comment out the On Error Resume Next statement.

Have you checked to see whether CDO is installed on this machine?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"OscarM" wrote in message ...
Hi,

I'm using the source code from
http://www.outlookcode.com/codedetail.aspx?id=139 along with CDO 1.21 to set
a calendar color label in Outlook.

It works from one pc, but it does not work from others. There are no errors.

Please help.

This is the code I'm using:

Dim objAppt As Outlook.AppointmentItem
Dim objFolder As MAPIFolder

' get Kaltron Calendar
Set objFolder = GetFolder("Public Folders/All Public Folders/Inbound
Water Transit")
' Set objFolder = GetFolder("Public Folders/Favorites/Inbound Water
Transit")

' create appointment on Kaltron Calendar
Set objAppt = objFolder.Items.Add("IPM.Appointment")

' set appointment properties
With objAppt
.Start = Me![EST SHIP DATE]
.Subject = "TEST PO #" & Me!PO & " " & Me!PRODUCT & " (" & Me![LOC
CODE] & ")"
.Body = "TEST PO #" & Me!PO & " " & Me!PRODUCT & " (" & Me![LOC CODE]
& ")"
.AllDayEvent = True
.Save

' set appointment label color based on LOC CODE
If Me![LOC CODE] = "KP" Then
Call SetApptColorLabel(objAppt, 3) 'green
ElseIf Me![LOC CODE] = "KUP" Then
Call SetApptColorLabel(objAppt, 2) 'blue
ElseIf Me![LOC CODE] = "DIRECT" Then
Call SetApptColorLabel(objAppt, 10) 'yellow
Else
Call SetApptColorLabel(objAppt, 1) 'red
End If

.Close (olSave)
End With



Sub SetApptColorLabel(objAppt1 As Outlook.AppointmentItem, _
intColor As Integer)
' requires reference to CDO 1.21 Library
' adapted from sample code by Randy Byrne
' intColor corresponds to the ordinal value of the color label
'1=Important, 2=Business, etc.
Const CdoPropSetID1 = "0220060000000000C000000000000046"
Const CdoAppt_Colors = "0x8214"
Dim objCDO As MAPI.Session
Dim objMsg As MAPI.MESSAGE
Dim colFields As MAPI.Fields
Dim objField As MAPI.Field
Dim strMsg As String
Dim intAns As Integer
On Error Resume Next

Set objCDO = CreateObject("MAPI.Session")
objCDO.Logon "", "", False, False
If Not objAppt1.EntryID = "" Then
Set objMsg = objCDO.GetMessage(objAppt1.EntryID, _
objAppt1.Parent.StoreID)
Set colFields = objMsg.Fields
Set objField = colFields.Item(CdoAppt_Colors, CdoPropSetID1)
If objField Is Nothing Then
Err.Clear
Set objField = colFields.Add(CdoAppt_Colors, vbLong, intColor,
CdoPropSetID1)
Else
objField.Value = intColor
End If
objMsg.Update True, True
Else
strMsg = "You must save the appointment before you add a color
label. " & _
"Do you want to save the appointment now?"
intAns = MsgBox(strMsg, vbYesNo + vbDefaultButton1, "Set Appointment
Color Label")
If intAns = vbYes Then
Call SetApptColorLabel(objAppt1, intColor)
Else
Exit Sub
End If
End If

Set objAppt1 = Nothing
Set objMsg = Nothing
Set colFields = Nothing
Set objField = Nothing
objCDO.Logoff
Set objCDO = Nothing
End Sub




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort calendar to view only events with the same color label? lista72 Outlook - Calandaring 2 August 9th 06 07:10 PM
Changing Calendar Label Description and Color James Felder Outlook - Calandaring 1 July 25th 06 03:28 PM
adding a new color label to the label list for Microsoft Outlook 2 CSS Tech Outlook - Calandaring 1 July 21st 06 05:57 PM
How do I add the Label color option to my appointments screen? townieflo Outlook - Calandaring 3 March 2nd 06 02:46 PM
Appointment Label colors - what are they in the color palette? deko Outlook and VBA 2 January 18th 06 08:45 AM


All times are GMT +1. The time now is 07:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.