It would need to run from Outlook, it just makes more sense that way
that when someone adds a calendar entry, the event code would pick it
up and start Excel.
Keep in mind this means you would need to install this code on every
users' machine that you want to receive this information from.
This should get you started. Place this code in the ThisOutlookSession
module of your Outlook. Then close and restart Outlook.
Private WithEvents CalItems As Outlook.Items
Private Sub Application_Startup()
Dim objNS As Outlook.NameSpace
Set objNS = GetNamespace("MAPI")
Set CalItems = objNS.GetDefaultFolder(olFolderCalendar).Items
End Sub
Private Sub CalItems_ItemAdd(ByVal Item As Object)
Dim Cal As Outlook.AppointmentItem
Dim XLApp As Object
Set Cal = Item
If InStr(Cal.Subject, "Annual Leave") > 0 Then
On Error Resume Next
Set XLApp = CreateObject("Excel.Application")
On Error GoTo 0
If XLApp Is Nothing Then GoTo ExitProc
XLApp.Workbooks("My Workbook.xls").Open
MsgBox "Your workbook is open"
XLApp.Quit
End If
ExitProc:
Set XLApp = Nothing
Set Cal = Nothing
End Sub
What this code does is check your Calendar whenever you add a new item
to the default "Calendar" folder. When a new appointment is placed, it
checks for the string "Annual Leave" in the subject. If it is found,
Excel is started and a workbook is opened. The sample code merely
displays a message box and then exits. You would need to adjust the
code for your particular needs.
For example, if you had a workbook on a shared network drive, change
"My Workbook.xls" to the full path and filename of the file you want
to add this information to.
HTH,
JP