I have been generating an access database to carry out scheduling of maintenance activities. The database will be used by a number of users using different computers which have a combination of Access 2007, 2010 and 2013 like wise they have the same mix for the Microsoft Outlook. I would like the routines generated within Access to be seen/posted on a calendar which is within the Public Folders in Outlook so that they can be seen by all personnel who have an outlook account. I have managed to achieve this direct from my computer but when the database is opened on another computer it does not work as it cannot find the Calendar in question. I have researched the issue and understand that addressing a folder in Outlook 2007 is different to 2010/13 hence I came to the conclusion that I need to use GetFolderFromID rather than drilling down through the folders as is suggested by many when researched on the Web. (I could not get the drill down to work anyway). Whilst sorting out the issue of getting it to work on all computers I have generated a form which writes post a short appointment to allow me to lay with the program without affecting the whole database. The code used is detailed. Does anyone have any idea why this will work every time from one computer but has only worked once or twice on others?
Code:
Private Sub Command14_Click()
If Me.Dirty Then
Me.Dirty = False
End If
' 'Add a new appointment.
' Use late binding to avoid the "Reference" issue
Dim olapp As Object ' Outlook.Application
Dim olappt As Object ' olAppointmentItem
' Dim mynamespace As Object
Dim olfolder1 As Object
If isAppThere("Outlook.Application") = False Then
' Outlook not open, create a new instance
Set olapp = CreateObject("Outlook.Application")
Else
' Outlook open--use this method
Set olapp = GetObject(, "Outlook.Application")
End If
' Set mynamespace = olapp.GetNamespace("MAPI")
Set olfolder1 = olapp.GetNamespace("MAPI")
'Dim olfolder1 As Outlook.MAPIFolder
Set olfolder1 = olapp.GetNamespace("Mapi").GetFolderFromID("000000001A447390AA6611CD9BC800AA001297860300BA636AB832B66B4A8E022C4576FGJ1123222891091827300")
Set olappt = olfolder1.Items.Add
' Set olappt = olapp.CreateItem(1) ' olAppointmentItem
With olappt
' Set the Start Property Value
.Start = Nz(Me.startDate, "")
' Set the End Property Value
.End = Nz(Me.Enddate, "")
' .Duration = Nz(Me.txtApptLength, 0) ' vbNullString uses a little less memory than ""
' .Subject = Nz(Me.cboApptDescription, vbNullString)
' .Body = Nz(Me.txtApptNotes, vbNullString)
.location = Nz(Me.location, vbNullString) & " " & Nz(Me.Task, vbNullString)
.Save
End With
' End If
' Release the Outlook object variables.
Set olfolder1 = Nothing
Set olappt = Nothing
Set olapp = Nothing
'Set chkAddedToOutlook to checked
' Me.chkAddedToOutlook = True
' Save the Current Record
If Me.Dirty Then
Me.Dirty = False
End If
' Inform the user
MsgBox "Appointment Added!", vbInformation
End Sub
I am confident that the address code for the public folder is correct as I have checked it from other computers so as I understand it the program should work from any computer but as I say it is perfect from the one computer using Access 2010 and Outlook 2010 but not from any of the others though it has worked on the odd occasions which makes the problem even more strange. The address for the public folder/calendar is \\Public Folder\All Public Folders\Maintenance Schedule.
I have now run out of ideas so would appreciate any help or pointers.
Regards
Phillipm