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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Enable/Disable Commandbar buttons



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old June 29th 07, 11:26 AM posted to microsoft.public.outlook.program_addins
Bodo
external usenet poster
 
Posts: 13
Default Enable/Disable Commandbar buttons

Hi,

The follwing code snipset is from a COM Add-in that I've build for Outlook
2002 SP3 . The addin enables/disables some commandbarbuttons from Outlook
commandbars depending on the users selection of a folder.

e.g.:
If the user clicks on public folder "A" commandbarbutton "Forward" from
"Actions"-Menu should be disabled.
If the user clicks on any other folder button "Forward" from "Actions"-Menu
should be enabled.
I picked the "Forward" button-id (=356) from Outlook-spy.

This works ok, but when the users selects an item from the folder "A" where
Forward-button should be disabled, the button actually gets enabled.

Enum MenuStatus
Enable = 1
Disable = 0
End Enum

Enum OutlookMenuCmdId
menuCmdID_Speichernunter = 748
menuCmdID_ImportExport = 2577
menuCmdID_Drucken = 4
menuCmdID_Kopieren = 19
menuCmdID_InOrdnerverschieben = 1679
menuCmdID_InOrdnerkopieren = 1676
menuCmdID_AlsvCardweiterleiten = 5573
menuCmdID_Weiterleiten = 356
menuCmdID_KontextDrucken = 2521
End Enum

Private Sub moActiveExplorer_FolderSwitch()
If moActiveExplorer.CurrentFolder.Name =
cPublicFolder_LV_Mitarbeiter Then
Outlook_EnableDisable_MenuItems (MenuStatus.Disable)
Else
Outlook_EnableDisable_MenuItems (MenuStatus.Enable)
End If
End Sub

Private Sub moActiveExplorer_SelectionChange()
If moActiveExplorer.CurrentFolder.Name =
cPublicFolder_LV_Mitarbeiter Then
Outlook_EnableDisable_MenuItems (MenuStatus.Disable)
Else
Outlook_EnableDisable_MenuItems (MenuStatus.Enable)
End If
End Sub


Public Sub Outlook_EnableDisable_MenuItems(EnableDisable As MenuStatus)
Dim oCmdBarMenu As Office.CommandBar
Dim oBarCrls As Office.CommandBarControls
Dim ocmdBarPopup As Office.CommandBarPopup
Dim Enabled As Boolean, CommandsInfo As String

On Error GoTo Outlook_EnableDisable_MenuItems_Err

Enabled = (EnableDisable = Enable)

SetCommandBarButton menuCmdID_Speichernunter, Enabled
SetCommandBarButton menuCmdID_AlsvCardweiterleiten, Enabled
SetCommandBarButton menuCmdID_Drucken, Enabled
SetCommandBarButton menuCmdID_ImportExport, Enabled
SetCommandBarButton menuCmdID_InOrdnerkopieren, Enabled
SetCommandBarButton menuCmdID_InOrdnerverschieben, Enabled
SetCommandBarButton menuCmdID_KontextDrucken, Enabled
SetCommandBarButton menuCmdID_Kopieren, Enabled
SetCommandBarButton menuCmdID_Weiterleiten, Enabled

Outlook_EnableDisable_MenuItems_Exit:
Exit Sub

Outlook_EnableDisable_MenuItems_Err:
MsgBox "Fehler in Outlook-Addin: " & Err.Description, vbExclamation
Resume Outlook_EnableDisable_MenuItems_Exit
End Sub

Private Sub SetCommandBarButton(ButtonID As OutlookMenuCmdId, ButtonEnabled
As Boolean)
Dim oBarButton As Office.CommandBarButton

Set moOfficeCmdBars = moActiveExplorer.CommandBars

Set oBarButton = moOfficeCmdBars.FindControl(, ButtonID)
If Not oBarButton Is Nothing Then
oBarButton.Enabled = ButtonEnabled
End If

Set oBarButton = Nothing
Set moOfficeCmdBars = Nothing
End Sub


Appreciate any clues.




--
Thanks in advance
Bodo
 




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
Disable sign and encrypt buttons [email protected] Add-ins for Outlook 0 June 20th 07 08:18 PM
Enable/Disable Macros when walking public folders in loop Matt Williamson Outlook and VBA 3 May 4th 07 03:28 PM
Disable offline buttons Rainer Treppmann Outlook - Installation 0 October 23rd 06 09:43 AM
Enable Disable the To textbox [email protected] Outlook - Using Forms 1 May 23rd 06 08:54 PM
Where is the group policy option to enable or disable 'Word as email editor' in Outlook XP? QH Outlook - General Queries 5 April 11th 06 03:47 PM


All times are GMT +1. The time now is 12:41 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-2025 Outlook Banter.
The comments are property of their posters.