adding an appointment to Outlook


G

Guest

Something is missing from this code, but I can't figure out what it is. This
posts an appointment to my personal calendar quite well, but doesn't post it
to my public folder. No error message - just goes into the personal calendar.

Any suggestions?

Private Sub OutLkBtn_Click()
On Error GoTo Add_Err
'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
'Exit the procedure if appointment has been added to outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft Outlook"
Exit Sub
'Add a new appointment
Else
Dim objoutlook As Outlook.Application
Dim nms As Outlook.Namespace
Dim fld As Outlook.MAPIFolder
Dim objappt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objoutlook = CreateObject("Outlook.Application")
Set nms = objoutlook.GetNamespace("MAPI")
Set fld = nms.Folders("Public Folders").Folders("all public
folders").Folders("Calendar")
Set objappt = objoutlook.CreateItem(olAppointmentItem)
With objappt
.Start = Me!ApptStartDate '& " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objappt = Nothing
'Release the object variables.
Set objoutlook = Nothing
Set objRecurPattern = Nothing
'Set the AddedToOutlook flag, save the record, display
'a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
'Visible = False
End If

Exit Sub
Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
 
Ad

Advertisements

D

David C. Holley

Bit rusty with Exchange related issues now that I've broken free of the
industrial, bourgeois, capitalist pig that is the W*** D***** Company,
but that aside...wouldn't you have to create the item in the public
folder as well OR grant permission for others to see your personal calendar.
 
G

Guest

The whole point is to create an item in public folders. I have designed a CRM
program in Access where our Calendar is located. I need the calendar there
for reporting purposes, which Outlook doesn't do well. The office
appointments also have to go in Outlook to synchronize with our Palm devices.
Supposedly this code will do that, but for some reason it isn't working.
 
Ad

Advertisements

D

David C. Holley

Try posting to this newsgroup: microsoft.public.outlook.program_vba

The Outlook goonies hanging out there should have the answer. I'm
thinking though that you may have to EXPLICITY create the
AppointmentItem in both folders. If that's the case it should be as easy
as changing the fld object variable to point to the other calendar AFTER
the objappt.save statement in the If...Then. From there do another
objappt.save and that should do it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top