![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
Enabled is a Boolean. Use True and False.
-- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Bodo" wrote in message ... 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 |
#3
|
|||
|
|||
![]()
Hi Ken,
I modified the sub to enable/dsable the buttons, which works fine now: Private Sub SetCommandBarButton(ButtonID As OutlookMenuCmdId, ButtonEnabled As Boolean) Dim ctrl As Office.CommandBarControl, cmdBar As Office.CommandBar If Not moOL.ActiveExplorer Is Nothing Then Set ctrl = moOL.ActiveExplorer.CommandBars.ActiveMenuBar.Find Control(, ButtonID, , True, True) If Not ctrl Is Nothing Then ctrl.Enabled = ButtonEnabled End If For Each cmdBar In moOL.ActiveExplorer.CommandBars If Not cmdBar Is Nothing Then 'If cmdBar.Type = msoBarTypeMenuBar Then Set ctrl = cmdBar.FindControl(, ButtonID, , True) ' Auflistung aller Controlls If Not ctrl Is Nothing Then ctrl.Enabled = ButtonEnabled End If End If Next End If Set cmdBar = Nothing Set ctrl = Nothing End Sub -- Thanks in advance Bodo "Ken Slovak - [MVP - Outlook]" wrote: Enabled is a Boolean. Use True and False. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Bodo" wrote in message ... 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 |
#4
|
|||
|
|||
![]()
Thanks in advance for what? Is there a question here or are you just showing
the code that works now? -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Bodo" wrote in message ... Hi Ken, I modified the sub to enable/dsable the buttons, which works fine now: Private Sub SetCommandBarButton(ButtonID As OutlookMenuCmdId, ButtonEnabled As Boolean) Dim ctrl As Office.CommandBarControl, cmdBar As Office.CommandBar If Not moOL.ActiveExplorer Is Nothing Then Set ctrl = moOL.ActiveExplorer.CommandBars.ActiveMenuBar.Find Control(, ButtonID, , True, True) If Not ctrl Is Nothing Then ctrl.Enabled = ButtonEnabled End If For Each cmdBar In moOL.ActiveExplorer.CommandBars If Not cmdBar Is Nothing Then 'If cmdBar.Type = msoBarTypeMenuBar Then Set ctrl = cmdBar.FindControl(, ButtonID, , True) ' Auflistung aller Controlls If Not ctrl Is Nothing Then ctrl.Enabled = ButtonEnabled End If End If Next End If Set cmdBar = Nothing Set ctrl = Nothing End Sub -- Thanks in advance Bodo |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |