PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

Appointment Label Color

 
 
=?Utf-8?B?T3NjYXJN?=
Guest
Posts: n/a
 
      30th Aug 2006
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



 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      30th Aug 2006
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" <(E-Mail Removed)> wrote in message news:4BC0DA43-61CE-48A2-B70A-(E-Mail Removed)...
> 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
>
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?T3NjYXJN?=
Guest
Posts: n/a
 
      1st Sep 2006
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" <(E-Mail Removed)> wrote in message news:4BC0DA43-61CE-48A2-B70A-(E-Mail Removed)...
> > 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
> >
> >
> >

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
color transition (color changes from dark color to light color) color transition Microsoft Powerpoint 2 21st Nov 2009 01:21 PM
How to color Outlook appointment? (label function not availabl... =?Utf-8?B?Y29uZnVzZWQgY29sb3IgY29kZXI=?= Microsoft Outlook Calendar 1 23rd Feb 2005 05:06 AM
Dim lbl( ) As Label = New Label( ){...} vs Dim lbl( ) As Label = {...} Ron Microsoft VB .NET 2 12th Nov 2004 11:35 PM
How to give a color/label to an appointment through vba Ciao Microsoft Outlook VBA Programming 2 15th May 2004 07:56 AM
How to get the currently selected appointment start & enddate of a single appointment in a recurring appointment series? Fredrik Nelson Microsoft Outlook VBA Programming 0 29th Apr 2004 04:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.