Hi, I have recently installed Codetwo Public Folders on my client's computers so they can shared one calendar including the category colours. It works great.
I have created an Access database to enter appointments into the calendar using the following line of code:
But I would like the appointments to post to the calendar without the user having to choose the calendar each time.
This code works fine on the host of the shared calendar but not on the other computers.
My issue is that I can't figure out how to make this happen. I have searched all over the internet but I haven't been able to find something that works, or that I can understand and adapt. (I am a self taught code writer...so not very good)
Support at Codetwo weren't able to shed any light either.
The Pickfolder window shows the following structure:
C2PublicFolders - Other User's Folders - HUNTLYJOINERY\Tony - Calendar - Deliveries
this is the full code that I am using in my database:
Any guidance is very much appreciated
I have created an Access database to enter appointments into the calendar using the following line of code:
Code:
Set olfolder = olapp.GetNamespace("mapi").PickFolder
This code works fine on the host of the shared calendar but not on the other computers.
Code:
Set olfolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Folders("Deliveries")
Support at Codetwo weren't able to shed any light either.
The Pickfolder window shows the following structure:
C2PublicFolders - Other User's Folders - HUNTLYJOINERY\Tony - Calendar - Deliveries
this is the full code that I am using in my database:
Code:
Private Sub cmdAddCalendars_Click()
Me.Dirty = False
If Me.chkAddedtoOutlook = True Then
MsgBox "This appointment has already been added to Microsoft Outlook", vbCritical
' Exit the procedure
Exit Sub
Else
' Add a new appointment.
' Use late binding to avoid the "Reference" issue
Dim olapp As Object ' Outlook.Application
Dim olappt As Object ' olAppointmentItem
Dim i As Integer
Dim ctl As Control
Dim cat As Control
Dim olfolder As Object
If isAppThere("Outlook.Application") = False Then
' Outlook is not open, create a new instance
Set olapp = CreateObject("Outlook.Application")
Else
' Outlook is already open--use this method
Set olapp = GetObject(, "Outlook.Application")
End If
Set olfolder = olapp.GetNamespace("mapi").PickFolder
Set olappt = olfolder.Items.Add ' olAppointmentItem
With olappt
' If There is no Start Date or Time on
' the Form use Nz to avoid an error
' Set the Start Property Value
.Start = Nz(Me.DelDate, "") & " " & Nz(Me.txtTime, "")
.Subject = Nz(Me.Delivery & " " & Me.OrderNumber & " " & Me.Customer & " " & Me.NumberofDoors, vbNullString)
.Mileage = Nz(Me.OrderNumber, vbNullString)
.Categories = Nz(Me.Stage, vbNullString)
.ReminderSet = False
.Save
End With
End If ' Release the Outlook object variables.
Set olappt = Nothing
Set olapp = Nothing ' Set chkAddedToOutlook to checked
Me.chkAddedtoOutlook = True
' Save the Current Record because we checked chkAddedToOutlook
Me.Dirty = False
' Inform the user
MsgBox "Appointment Added!", vbInformation
End Sub
Function isAppThere(appname) As Boolean
On Error Resume Next
Dim objApp As Object
isAppThere = True
Set objApp = GetObject(, appname)
If Err.Number <> 0 Then isAppThere = False
End Function