H
Hotwheels
I get the type missmatch error when the code below trys to use
"For Each Appt In CalendarFolder.Items" .
The code works fine on 2000 and XP, one 2000 machine is using
Outlook 2003 sp1 fine with this code.
Is there a know problem with XP Prof and Outlook 2003 sp1?
Is there a work around I can use to go thru all the appointments
and find the one I want to alter.
Mike
Private mOut As Outlook.Application
Private Sub cmdMakeApp_Click()
Dim Prp As UserProperty
Dim i As Long
Dim bFound As Boolean
Dim MAPINameSpace As Outlook.NameSpace
Dim CalendarFolder As Outlook.MAPIFolder
Dim Appt As Outlook.AppointmentItem
On Error GoTo eh
bFound = False
If (mOut Is Nothing) Then Set mOut = CreateObject("Outlook.Application")
Set MAPINameSpace = mOut.GetNamespace("MAPI")
MAPINameSpace.Logon
Set CalendarFolder = MAPINameSpace.GetDefaultFolder(olFolderCalendar)
If (chkExsist.Value = 1) Then
For Each Appt In CalendarFolder.Items 'Problem place
If Not (Appt.UserProperties.Item("IDInteraction") Is Nothing) Then
If Appt.UserProperties.Item("IDInteraction").Value =
txtLabel.Text Then
bFound = True
Exit For
End If
End If
Next
End If
Set MAPINameSpace = Nothing
Set CalendarFolder = Nothing
If Not bFound Then Set Appt = mOut.CreateItem(olAppointmentItem)
Appt.Subject = "A Test"
Appt.Body = " A Test Appointment"
Appt.Location = "3rd Floor"
Appt.Start = "2/9/2005" + " " + "2:00 AM"
Appt.End = "2/9/2005" + " " + "3:00 AM"
If Not bFound Then Appt.UserProperties.Add "IDInteraction", olText
If (Not Appt Is Nothing) Then
If Not (bFound) Then
Appt.Save
If (mstrInteractionID = "") Then
Appt.UserProperties.Item("IDInteraction").Value =
txtLabel.Text
Else
oApp.UserProperties.Item("IDInteraction").Value =
txtLabel.Text
End If
Else
Appt.UserProperties.Item("IDInteraction").Value =
txtLabel.Text
End If
Appt.Save
End If
Set Appt = Nothing
Set mOut = Nothing
Unload Me
Exit Sub
eh:
Set mOut = Nothing
Err.Raise Err.Number, , Err.Description
Unload Me
End Sub
"For Each Appt In CalendarFolder.Items" .
The code works fine on 2000 and XP, one 2000 machine is using
Outlook 2003 sp1 fine with this code.
Is there a know problem with XP Prof and Outlook 2003 sp1?
Is there a work around I can use to go thru all the appointments
and find the one I want to alter.
Mike
Private mOut As Outlook.Application
Private Sub cmdMakeApp_Click()
Dim Prp As UserProperty
Dim i As Long
Dim bFound As Boolean
Dim MAPINameSpace As Outlook.NameSpace
Dim CalendarFolder As Outlook.MAPIFolder
Dim Appt As Outlook.AppointmentItem
On Error GoTo eh
bFound = False
If (mOut Is Nothing) Then Set mOut = CreateObject("Outlook.Application")
Set MAPINameSpace = mOut.GetNamespace("MAPI")
MAPINameSpace.Logon
Set CalendarFolder = MAPINameSpace.GetDefaultFolder(olFolderCalendar)
If (chkExsist.Value = 1) Then
For Each Appt In CalendarFolder.Items 'Problem place
If Not (Appt.UserProperties.Item("IDInteraction") Is Nothing) Then
If Appt.UserProperties.Item("IDInteraction").Value =
txtLabel.Text Then
bFound = True
Exit For
End If
End If
Next
End If
Set MAPINameSpace = Nothing
Set CalendarFolder = Nothing
If Not bFound Then Set Appt = mOut.CreateItem(olAppointmentItem)
Appt.Subject = "A Test"
Appt.Body = " A Test Appointment"
Appt.Location = "3rd Floor"
Appt.Start = "2/9/2005" + " " + "2:00 AM"
Appt.End = "2/9/2005" + " " + "3:00 AM"
If Not bFound Then Appt.UserProperties.Add "IDInteraction", olText
If (Not Appt Is Nothing) Then
If Not (bFound) Then
Appt.Save
If (mstrInteractionID = "") Then
Appt.UserProperties.Item("IDInteraction").Value =
txtLabel.Text
Else
oApp.UserProperties.Item("IDInteraction").Value =
txtLabel.Text
End If
Else
Appt.UserProperties.Item("IDInteraction").Value =
txtLabel.Text
End If
Appt.Save
End If
Set Appt = Nothing
Set mOut = Nothing
Unload Me
Exit Sub
eh:
Set mOut = Nothing
Err.Raise Err.Number, , Err.Description
Unload Me
End Sub