Outlook Programming : How to get the File Menu commands programmatically?
This time we will try using the Outlook Object model, we can able to get the Outlook File Menu commands programmatically (I tried with Outlook 10)
1: ...
2: ' First get the ActiveExplorer
3: Dim oExp As Outlook.Explorer = oApp.ActiveExplorer()
4:
5: ' Then get the menu bar.
6: Dim oCmdBars As Office._CommandBars = oExp.CommandBars
7: Dim oCmdBar As Office.CommandBar = oCmdBars("Menu Bar")
8: 'If needed display the CommandBar Name
9: Console.WriteLine(oCmdBar.Name)
10:
11: ' Get the controls
12: Dim oBrCrls As Office.CommandBarControls = oCmdBar.Controls
13:
14: ' Then get the File menu.
15: Dim oBPop As Office.CommandBarPopup = oBrCrls("File")
16: ' If needed display the caption
17: Console.WriteLine(oBPop.Caption)
18: oBrCrls = oBPop.Controls
19:
20: ' Then loop each menu & display the caption
21: Dim oBtn As Office.CommandBarControl
22: For Each oBtn In oBrCrls
23: Console.WriteLine(oBtn.Caption)
24: Next
25: ....