How can I view Group Schedules programmatically ?

  • Thread starter Thread starter Siddharth
  • Start date Start date
S

Siddharth

Hi,

I am creating a Macro by clicking which I should get a pre made Group
schedules window. I am running the macro from inbox so that user dont
have to 1. go to Calender,
2. then click on View Group Schedules and
3. then create a Group and t
4. hen check the Free/Busy.

I want to make this process easy for our users. The group here never
changes. Is this possible ????? (Or) is there any other way for this?
I am on Outlook XP Client and Exchange 2003 server.
 
You can certainly get the free/busy information for a Recipient or
AddressEntry object, but not for a group using code. The Recipient.FreeBusy
and AddressEntry.GetFreeBusy functions (methods) would be used. The return
for those methods is a free/busy string where you get "1" or "0" for each
time period to denote free or busy. From there you parse the strings and do
your own testing for when everyone is free.
 
Hi Ken,

As always Thank you for replying and helping us all. I will try to do
what you have suggested.
But wondering is there any way to access the pop window/form that View
Group Resource renders. My use case is an attempt to group all our
conference rooms and show their free/busy status to all of our users
from inbox. They can click on that macro and see the status and invite
attendees and book any of available conference (already set as
resources) for meeting.

Any suggestions will be helpful..

regards,
Siddharth.
 
You can certainly open an appointment/meeting form and even get tricky and
go to the scheduling tab, but you can only get to the Group Schedules form
or as close to it as possible by navigating the Outlook menu structure using
code.

You would get the ID of the button you want to click and find that control
and call its .Execute method, or progressively set CommandBarPopup and
CommandBarButton and CommandBarControl objects to the layers of that menu,
starting at "Menu Bar" as a CommandBar and call the final button object's
..Execute method. That's about the only way I can think of to get there.
 
Thank you Ken. I will see what can I come up with and post here. I
thought there might be little easier way than this.
 
Not that I know of, and one other thing. Since there are multiple Actions
menus you would have to change the ActiveExplorer.CurrentFolder to a
calendar folder before the Actions menu for calendar folders becomes
available to you.
 
Hi,

Instead of macro I found out this great form that serves my purpose to
50%.
I am attaching that form
(I cannot attach form I guess, I have to attach the code)with this
mail.
This is the form created by one of the outlook's MVPs. Its an old one
but found out over web. Now my task is to some how enable this form to
make an appointment by clicking on the same row and time as
availability of resource to book that particular resourse.
(Same as pop of "view group schedules").

This form just opens up with the free busy calender then I added all
our conference rooms and published it. You might have saw this one
before.

Option Explicit

Dim oInspector ' Inspector object
Dim oCommandBar ' Toolbar object
Dim oCommandBars ' Command Bars objext
Dim oStandardBar ' Standard Toolbar object
Dim oMenuBar ' Standard Menubar object
Dim oFileMenu ' Standard Filemenu object
Dim oRecipients ' Recipient object
Dim UserName ' UserName
Dim oUser ' User object
Dim oSession ' MAPI session
Dim RetCode ' Return Code of MAPI Logon
Dim oAddressList ' Addresslist object
Dim oDistributionList ' Address object
Dim Counter ' Counter
Dim MemberCount ' Members of the DL
Dim OpenItem ' Item is in the open event

Set oInspector = Nothing
Set oCommandBar = Nothing
Set oStandardBar = Nothing
Set oMenuBar = Nothing
Set oDistributionList = Nothing
Set oAddressList = Nothing

MemberCount = 0
Counter = 1
OpenItem = False

Function Item_Open()

' Set flag until item_open event is not finished
OpenItem = True

' Create MAPI Session
Set oSession = Application.CreateObject("MAPI.Session")
RetCode = oSession.Logon(Application.GetNameSpace("MAPI").CurrentUser,
"", False, False, 0)

' Get UserName
UserName = oSession.CurrentUser

' If UserName not found
If Trim(UserName) = "" Then

' Error creating MAPI session, show error message and exit
MsgBox "Undefinied error. Errorcode: " & RetCode & ". Please contact
your System Administrator", 48, "Microsoft Outlook"
Item_Open = False
Else
RetCode = "OK"
End If

' Hide Standard Toolbar
Set oInspector = Item.Application.ActiveInspector
Set oCommandBar = oInspector.CommandBars.Item("Standard")
oCommandBar.Visible = False

' Set Subject (it looks pretty better than <untitled>, or ?)
Item.Subject = "Show Free/Busy Times"

' Set start and duration time
Item.Start = Date + #12:00:01 PM#
Item.Duration = 0

' Disable reminder
Item.ReminderSet = False
Item.ReminderMinutesBeforeStart = 0

' Delete first Recipient (That's always the current user)
Item.Recipients(1).Delete

' Check CDO/Outlook Version
If Left(oSession.Version,3) = "1.0" Then

' Too bad, that's to old, show error message and exit
Msgbox "You must at least have Outlook 97 8.01 or higher installed
to show the Free/Busy Times Form", 48, "Microsoft Outlook"

' Show the Standard Toolbar
oCommandBar.Visible = True

' Release objects
Set oDistributionList = Nothing
Set oAddressList = Nothing
Set oInspector = Nothing
Set oCommandBar = Nothing
Set oCommandBars = Nothing
Set oStandardBar = Nothing
Set oMenuBar = Nothing
Set oFileMenu = Nothing
Counter = 0

' Prevent item from opening
Item_Open = False
End If

' Check if CDO/Outlook Version is CDO 1.2 or higher
' otherwise we can't use the addresslists collection because Outlook
97 8.03
' crashes if we try to set oAddressList =
oSession.AddressLists("Global Address List")
If Left(oSession.Version,3) = "1.2" Then

' Get the global address list
On Error Resume Next
Set oAddressList = oSession.AddressLists("Global Address List")

' Can't find the global address list online, maybe we are offline
If oAddressList Is Nothing Then
On Error Resume Next
Set oAddressList = oSession.AddressLists("Global Address List
(Offline)")
End If

' Set distribution list Everyone
Set oDistributionList = oAddressList.AddressEntries("Everyone")

' Check for possible errors
If Not oDistributionList Is Nothing Then

' Get the members count
MemberCount = oDistributionList.Members.Count

' Loop through the list and add each member
For Counter = 1 To oDistributionList.Members.Count

' Only add members who are of the type mailbox
If oDistributionList.Members(Counter).DisplayType = 0 Then
Item.Recipients.Add oDistributionList.Members(Counter).Address
End If
Next

' We need to show the item to refresh the free/busy times for all
added members
Item.Display

' Resolve all members against the Exchange Directory
Item.Recipients.Resolveall
Else

' Distribution list "Everyone" not found, show default address book
dialog
Set oRecipients = Nothing
On Error Resume Next
Set oRecipients = oSession.AddressBook(,"Choose name:",True,,0)

' Check if a valid recipient is selected
If Trim(oRecipients.Item(1).Name) <> "" Then

' Set the name of the selected recipient
Set oDistributionList =
oAddressList.AddressEntries(oRecipients.Item(1).Name)

' If the selected recipient us a distribution list
If oDistributionList.DisplayType = 1 Then

' Get the count of the members
MemberCount = oDistributionList.Members.Count

' Loop through the list and add each member
For Counter = 1 To oDistributionList.Members.Count

' Only add members of the type mailbox
If oDistributionList.Members(Counter).DisplayType = 0 Then
Item.Recipients.Add oDistributionList.Members(Counter).Address
End If
Next

' We need to show the item to refresh the free/busy times for all
added members
Item.Display

' Resolve all members against the Exchange Directory
Item.Recipients.Resolveall
ElseIf oDistributionList.DisplayType = 0 Then

' Selected recipient is a mailbox
Item.Recipients.Add oRecipients.Item(1).Name

' We need to show the item to refresh the free/busy times for all
added members
Item.Display

' Resolve against the Exchange Directory
Item.Recipients.Resolveall
Else

' Selected recipient is neither a DL nor a mailbox, show error
message and exit
MsgBox "Sorry, we can only show Free/Busy Times for a mailbox and
the members of a particular distribution list",48,"Microsoft Outlook"

' Show the Standard Toolbar
oCommandBar.Visible = True

' Release objects
Set oDistributionList = Nothing
Set oAddressList = Nothing
Set oInspector = Nothing
Set oCommandBar = Nothing
Set oCommandBars = Nothing
Set oStandardBar = Nothing
Set oMenuBar = Nothing
Set oFileMenu = Nothing
Counter = 0

' Prevent item from opening
Item_Open = False
End If
End If
End If
End If

' Disable Send Button in the Standard Toolbar
Set oCommandBars = Item.GetInspector.CommandBars
Set oStandardBar = oCommandBars("Standard")
Counter = 1
For Counter = 1 To oStandardBar.Controls.Count
If oStandardBar.Controls(Counter).ID = "2617" Then
oStandardBar.Controls(Counter).Enabled = False
Exit For
End If
Next

' Disable Send option in the File Menu
Set oMenuBar = oCommandBars.Item("Menu Bar")
Set oFileMenu = oMenuBar.Controls(1)
Counter = 1
For Counter = 1 To oMenuBar.Controls.Count
If oFileMenu.Controls(Counter).ID = "3037" Then
oFileMenu.Controls(Counter).Enabled = False
Exit For
End If
Next

' Reset Meeting Status
Item.MeetingStatus = 0

' Set start and duration time
Item.Start = Date + #12:00:01 PM#
Item.Duration = 0

' In some cases the display isn't refreshed correct, so refresh the
display here again
Item.Display

' Reset flag because the item_open event is finished now
OpenItem = False
End Function

Function Item_Write()
Item_Write = False
End Function

Function Item_Forward (ByVal ForwardItem)
Item_Forward = False
End Function

Function Item_Send()
Item_Send = False
End Function

Function Item_Close()

' Close MAPI Session
If RetCode = "OK" Then
RetCode = oSession.Logoff
RetCode = ""
End If

' Show the Standard Toolbar
oCommandBar.Visible = True

' Enable Send Button in the Standard Toolbar
Counter = 1
For Counter = 1 To oStandardBar.Controls.Count
If oStandardBar.Controls(Counter).ID = "2617" Then
oStandardBar.Controls(Counter).Enabled = True
Exit For
End If
Next

' Enable Send option in the File Menu
Counter = 1
For Counter = 1 To oMenuBar.Controls.Count
If oFileMenu.Controls(Counter).ID = "3037" Then
oFileMenu.Controls(Counter).Enabled = True
Exit For
End If
Next

' Release objects
Set oDistributionList = Nothing
Set oAddressList = Nothing
Set oInspector = Nothing
Set oCommandBar = Nothing
Set oCommandBars = Nothing
Set oStandardBar = Nothing
Set oMenuBar = Nothing
Set oFileMenu = Nothing
Counter = 0

' Close item without saving
Item.Close(1)
End Function

Sub Item_PropertyChange(ByVal Name)

' Each time the list with the attendees is modified,
' Outlook enables the Send Button in the Toolbar and the Send option
in the File Menu
' We have now to disable it again if we are not in the item_open
event
' because during this event the attendees are added to the form
programmatically
' and we have not to run into this Item_PropertyChange event until
the item_open is finished
' then we can disable the Send Button and Send option in the File
Menu

' Check if we are not in the item_open event
If OpenItem = False Then

' If count of DL members greater 0
If MemberCount > 0 Then

' If count of recipients has been changed
If MemberCount <> Item.Recipients.Count Then

' Disable Send Button again
Counter = 1
For Counter = 1 To oStandardBar.Controls.Count
If oStandardBar.Controls(Counter).ID = "2617" Then
oStandardBar.Controls(Counter).Enabled = False
Exit For
End If
Next

' Disable Send option in the File Menu again
Counter = 1
For Counter = 1 To oMenuBar.Controls.Count
If oFileMenu.Controls(Counter).ID = "3037" Then
oFileMenu.Controls(Counter).Enabled = False
Exit For
End If
Next
End If
End If
End If
End Sub
''End OF CODE

Any suggestons/options Ken to make the form clickable and book
resource through it.
 
I don't know and I don't have the time to go through all that code or to
evaluate a custom form for you. I'd suggest doing as much as you can
yourself and then posting back in a new thread as to what you are stumped
with.




Siddharth said:
Hi,

Instead of macro I found out this great form that serves my purpose to
50%.
I am attaching that form
(I cannot attach form I guess, I have to attach the code)with this
mail.
This is the form created by one of the outlook's MVPs. Its an old one
but found out over web. Now my task is to some how enable this form to
make an appointment by clicking on the same row and time as
availability of resource to book that particular resourse.
(Same as pop of "view group schedules").
<snip>
 
Ok Ken, Thank for helping me out.

Ken Slovak - said:
I don't know and I don't have the time to go through all that code or to
evaluate a custom form for you. I'd suggest doing as much as you can
yourself and then posting back in a new thread as to what you are stumped
with.





<snip>
 
Back
Top