![]() |
Adding a Meeting Room Resource - Code attached
Well, thanks to the folks here on this group I was able to write the
VBA code needed to add a meeting room to an open meeting. I thought I would share the code here for others to use or improve upon. This code would be attached to a form with; 1) listbox (lbxRooms) 2) button (cmdCancel) I then created a macro attached to the meeting schedule window to load and show the form when activated. regards, DP ==============code================= Option Explicit Dim strCity As String 'city code used in address name Dim strRooms As String 'address entries Dim Meeting 'current meeting Dim myRecipient 'the room I finally pick Dim UseThisRoom 'the room I finally pick Dim myAddressList As AddressList 'address list Dim AddressEntry As AddressEntry 'addressentry Private Sub UserForm_Initialize() Call GetRooms End Sub Sub GetRooms() 'use the global address book, incase another is default Set myAddressList = Application.Session.AddressLists("Global Address List") ' go through address book and get each meeting room For Each AddressEntry In myAddressList.AddressEntries strRooms = AddressEntry.Name 'look only at mtgrm entries (all room anmes begin with mtgrm) If Left(strRooms, 5) = "mtgrm" Then 'look for the available rooms Call GetFreeBusyInfo End If Next End Sub Sub GetFreeBusyInfo() Dim myFBInfo As String 'getfreebusy information for the meeting date Dim MyStart 'meeting start tiem and date Dim MyDur 'number of minutes in length the meeting is Dim MyStartTime 'number of minutes after midnight meeting starts 'use the active meeting as reference Set Meeting = Outlook.ActiveInspector.CurrentItem MyStart = Meeting.Start 'get the meeting start from active meeting MyDur = Meeting.Duration - 1 'get dureation from active meeting 'get number of minutes between midnight and MyStart MyStartTime = DateDiff("n", (Format(MyStart, "Short Date") & " 12:00:00 AM"), MyStart) On Error GoTo ErrorHandler 'ignore rooms that where freebusy is not available 'get the freebusy time for the meetign date myFBInfo = AddressEntry.GetFreeBusy(MyStart, 1) 'see if time is available (all minutes within meeting duration are 0) If Mid(myFBInfo, MyStartTime, MyDur) = 0 Then 'if available add it to the listbox lbxRooms.AddItem AddressEntry.Name End If ErrorHandler: End Sub Private Sub lbxRooms_DblClick(ByVal Cancel As MSForms.ReturnBoolean) 'use the room that is double clicked on UseThisRoom = lbxRooms.Value 'add the selected room to current object as a resource Set Meeting = Outlook.ActiveInspector.CurrentItem Set myRecipient = Meeting.Recipients.Add(UseThisRoom) myRecipient.Type = olResource 'unload form after room is added, since only one room is ever needed Unload Me End Sub Private Sub cmdCancel_Click() 'cancel and close the form without adding a room Unload Me End Sub |
All times are GMT +1. The time now is 03:37 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com