This sub pulls Outlook Appointments into a table.
The problem is I want to limit the import to Location = Boston
I'm not sure how to code that into the For... To loop - As it is now, I get
the following error:
Run-time error '3163':
The field is too small to accept the amount of data you attempted to add.
Try inserting less data.
Any suggestions very welcome!!! Thanks in advance...
Public Sub Import()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblAppointments")
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.AppointmentItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim iNumApts As Integer
Dim i As Integer
Dim lngEid As Long
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderCalendar)
Set objItems = cf.Items
iNumApts = objItems.Count
If iNumApts <> 0 Then
For i = 1 To iNumApts
If TypeName(objItems(i)) = "AppointmentItem" Then
Set c = objItems(i)
If c.Location = Boston Then
rst.AddNew
rst!Location = c.Location
rst!Date = c.Start
rst!Subject = c.Subject
rst.Update
End If
End If
Next i
rst.Close
End If
End Sub