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.