Finding Visible Controls with FindControls : CommandBar « Application « VBA / Excel / Access / Word

VBA / Excel / Access / Word
1. Access
2. Application
3. Data Type
4. Data Type Functions
5. Date Functions
6. Excel
7. File Path
8. Forms
9. Language Basics
10. Math Functions
11. Outlook
12. PowerPoint
13. String Functions
14. Windows API
15. Word
16. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » Application » CommandBar 
Finding Visible Controls with FindControls
 
Sub FindVisibleControls()
    Dim ctrls As CommandBarControls
    Dim ctrl As CommandBarControl

    Set ctrls = Application.CommandBars.FindControls(, , , True)

    For Each ctrl In ctrls
        Debug.Print ctrl.Parent.name
        Debug.Print ctrl.Caption
        Debug.Print ctrl.Index
        Debug.Print ctrl.ID
        Debug.Print ctrl.Enabled
        Debug.Print ctrl.Visible
        Debug.Print ctrl.IsPriorityDropped
        Debug.Print TranslateControlType(ctrl.Type)
    Next
    Set ctrl = Nothing
    Set ctrls = Nothing
End Sub
Function TranslateControlType(vType As MsoControlTypeAs String
    Dim sType As String

    Select Case vType
        Case Is = MsoControlType.msoControlActiveX
            sType = "ActiveX"
        Case Is = MsoControlType.msoControlAutoCompleteCombo
            sType = "Auto Complete Combo"
        Case Is = MsoControlType.msoControlButton
            sType = "Button"
        Case Is = MsoControlType.msoControlButtonDropdown
            sType = "Button Dropdown"
        Case Is = MsoControlType.msoControlButtonPopup
            sType = "Button Popup"
        Case Is = MsoControlType.msoControlComboBox
            sType = "Combo Box"
        Case Is = MsoControlType.msoControlCustom
            sType = "Custom"
        Case Is = MsoControlType.msoControlDropdown
            sType = "Dropdown"
        Case Is = MsoControlType.msoControlEdit
            sType = "Edit"
        Case Is = MsoControlType.msoControlExpandingGrid
            sType = "Expanding Grid"
        Case Is = MsoControlType.msoControlGauge
            sType = "Gauge"
        Case Is = MsoControlType.msoControlGenericDropdown
            sType = "Generic Dropdown"
        Case Is = MsoControlType.msoControlGraphicCombo
            sType = "Graphic Combo"
        Case Is = MsoControlType.msoControlGraphicDropdown
            sType = "Graphic Dropdown"
        Case Is = MsoControlType.msoControlGraphicPopup
            sType = "Graphic Popup"
        Case Is = MsoControlType.msoControlGrid
            sType = "Grid"
        Case Is = MsoControlType.msoControlLabel
            sType = "Label"
        Case Is = MsoControlType.msoControlLabelEx
            sType = "Label Ex"
        Case Is = MsoControlType.msoControlOCXDropdown
            sType = "OCX Dropdown"
        Case Is = MsoControlType.msoControlPane
            sType = "Pane"
        Case Is = MsoControlType.msoControlPopup
            sType = "Popup"
        Case Is = MsoControlType.msoControlSpinner
            sType = "Spinner"
        Case Is = MsoControlType.msoControlSplitButtonMRUPopup
            sType = "Split Button MRU Popup"
        Case Is = MsoControlType.msoControlSplitButtonPopup
            sType = "Split Button Popup"
        Case Is = MsoControlType.msoControlSplitDropdown
            sType = "Split Dropdown"
        Case Is = MsoControlType.msoControlSplitExpandingGrid
            sType = "Split Expanding Grid"
        Case Is = MsoControlType.msoControlWorkPane
            sType = "Work Pane"
        Case Else
            sType = "Unknown control type"
    End Select

    TranslateControlType = sType
End Function

 
Related examples in the same category
1. CommandBar Object
2. Creating a Toolbar and display MsgBox in its action
3. Creating a Toolbar and assign its action
4. Get the type of CommandBars
5. Creating a Toolbar: AddRemoveButton
6. Add ControlButton to CommandBar
7. Add PopupControl to CommandBar
8. Set Control style, Action, group, faceid and caption
9. Show All Toolbar Controls
10. Show CommandBar Names
11. Create Shortcut
12. show/hide check symbol
13. Save list of all predefined commands and their ID numbers in a file
14. Shows or hides a command bar.
15. Inspecting a CommandBar
16. Display Control Detail
17. Translates a MsoControlType enumeration into a text description of the control type.
18. Add a new commandbar
19. display shortcut menu with the ShowPopup method
20. Custom Toolbars
21. Removes a toolbar specified by the name passed in
22. Creating a command bar: Set some properties when you create a new toolbar
23. Referring to command bars
24. Counting custom toolbars
25. The Protection property of a CommandBar object provides you with many options for protecting a CommandBar.
26. The Protection constants are additive: apply different types of protection with a single command
27. how your VBA code can change the position of a toolbar.
28. This toolbar exists only when the cell pointer falls within a given range
29. Removing all toolbars and then restoring them
30. Restore tool bar
31. displays the Caption property for the first Control object contained in the Standard toolbar, whose index is 3.
32. Rather than use an index number to refer to a control, you can use its Caption property setting
33. Listing the controls on a command bar
34. Listing all controls on all toolbars
35. Adding a control to a command bar
36. To delete a control from a CommandBar object, use the Delete method of the Controls collection
37. deletes a control that has a caption of SortButton.
38. sets the FaceId property of the first button on the MyToolbar toolbar image to 45, which is the code number for a mailbox icon.
39. Adjusting a control's Visible property
40. Changing a control's caption dynamically: Showing the user the current cell's number format
41. simply copies the NumberFormat property of the ActiveCell to the Caption property of the button control.
42. Attaching a drop-down list to a command bar
43. CommandBars collection
44. Replacing Excel's built-in menu with your own
45. Working with Shortcut Menus
46. Properties of CommandBar controls
47. Reset CommandBar
48. The custom toolbar is removed with this procedure
49. Translates a MsoBarType enumeration into a text description of the bar type.
50. Translates a MsoBarPosition enumeration into a text description of the bar position.
51. Determines if a given command bar name exists
52. Restores the Worksheet Menu Bar to its native state
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.