A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Post to additional public calendar



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old December 21st 06, 12:11 AM posted to microsoft.public.outlook.program_vba
Penny Miller
external usenet poster
 
Posts: 34
Default Post to additional public calendar

I have created a form that is a time off request so when it is sent to the supervisor she/he can either approve or deny the employees time off. If she/he approves the time off, it sends the employee a message stating so and allows them to click and drag to their own calendar. Also, it will copy this information and place it on a public calendar for their division. If she/he deny's this request, it sends a message stating so and does nothing else. So far it works like a charm!

The problem is that the department head would like it to not only to post to the divisions calendar but also the departments global calendar and I'm not sure of the correct code to use. Can someone lead me in the right direction?

Here is my code;

Option Explicit

Dim mstrToffFolder ' public Time Off folder

Const olOutOfOffice = 3
Const olAppointmentItem = 1
Const olByValue = 1

Sub InitOpts()
' set user options

'public Time Off folder name and path
mstrToffFolder = "Public Folders/All Public Folders/Community Development/Calendar - Code Enforcement"
End Sub

Function Item_Open()
If Item.Size 0 Then
InitOpts
End If
End Function

Function Item_CustomAction(ByVal Action, ByVal NewItem)
Dim objAppt
Dim objAttachment
Dim objFolder
Dim dteStart
Dim dteEnd

Select Case Action.Name
Case "Approve"
' create appointment for user to save to calendar
dteStart = _
Item.UserProperties("TimeOffStart")
dteEnd = _
Item.UserProperties("TimeOffEnd")
Set objAppt = _
Application.CreateItem(olAppointmentItem)
With objAppt
..Start = dteStart
..End = dteEnd
..ReminderSet = False
..Subject = Item.Subject
..Body = Item.Body
..AllDayEvent = False
..BusyStatus = olOutOfOffice
End With
objAppt.Save
Set objAttachment = NewItem.Attachments.Add( _
objAppt, olByValue, , _
"Your Time Off")
NewItem.Body = "Your time off has been " & _
"approved. Drag the attached " & _
"Appointment to your Calendar. " & _
"Or, open it, then use File | Copy to Folder." & vbCrLf & vbCrLf
' move appointment to public folder
objAppt.Subject = Item.SenderName & " - " & Item.Body
Set objFolder = GetMAPIFolder(mstrToffFolder)
If Not objFolder Is Nothing Then
objAppt.Move objFolder
End If

Case Else
'do nothing special for other actions
End Select
' dereference objects
Set objAppt = Nothing
Set objAttachment = Nothing
Set objFolder = Nothing
End Function


Function GetMAPIFolder(strName)
Dim objApp
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim objExpl
Dim I
Dim blnFound

Set objApp = Application
Set objNS = objApp.GetNamespace("MAPI")
arrName = Split(strName, "/")
Set objFolders = objNS.Folders
blnFound = False
For I = 0 To UBound(arrName)
For Each objFolder In objFolders
If objFolder.Name = arrName(I) Then
Set objFolders = objFolder.Folders
blnFound = True
Exit For
Else
blnFound = False
End If

Next
If blnFound = False Then
Exit For
End If

Next
If blnFound = True Then
Set GetMAPIFolder = objFolder
Else
Set GetMAPIFolder = Nothing
End If

Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objFolders = Nothing
Set objExpl = Nothing

End Function

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make an additional calendar folder the default calendar fol Saf Outlook - Calandaring 1 July 22nd 06 06:46 PM
Share an additional calendar - NOT my regular calendar - with a gr Megoodgal Outlook - Calandaring 6 June 20th 06 08:33 PM
Public Folders messages in Outlook 2003 appearing as a 'Post' and not as a 'Message' [email protected] Outlook - General Queries 2 March 16th 06 03:51 AM
Is there an easy way to add holidays to an ADDITIONAL calendar? Julie Outlook - Calandaring 1 March 1st 06 07:35 PM
Additional calendar: adding holidays jozzer Outlook - Calandaring 1 February 27th 06 09:33 PM


All times are GMT +1. The time now is 12:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.