Share via

How to access Properties of objects in Excel VBA

Alan Sears 0 Reputation points
2026-05-05T12:50:37.8666667+00:00

Things seem to have changed in VBA since I last wrote any code. I am designing a small project for home use, using Excel and VBA. I find I can add controls to a userform but I cannot change their properties at design time. For example, I have a CommandButton which I want to rename, but I cannot open a useful Properties Window (F4). I have changed Activex preferences in the Trust Centre but Nothing seems to have any effect. Advice, please?

Developer technologies | Visual Basic for Applications
0 comments No comments

3 answers

Sort by: Most helpful
  1. Jack Dang (WICLOUD CORPORATION) 17,340 Reputation points Microsoft External Staff Moderator
    2026-05-06T03:51:23.9166667+00:00

    Hi @Alan Sears ,

    Thanks for reaching out.

    This comes down to the context in the VBA editor rather than a change in VBA itself. The key is to make sure you’re editing the control from the UserForm designer. Open the editor with Alt + F11, then in Project Explorer double-click the UserForm so it’s open in design view. Click the specific control once so only that control is selected, and then either press F4 or go to View -> Properties Window.

    When the correct object is selected, the Properties window should show entries like (Name) and Caption. (Name) is what you reference in code, while Caption is the text displayed on the control. If what opens doesn’t look like that, it’s often because the code window is active instead of the form, the form itself is selected, or multiple controls are selected at once.

    If you’re working with a control placed directly on a worksheet rather than inside a UserForm, switch on Design Mode from the Developer tab first, then access Properties from there or by right-clicking the control.

    If the Properties window still doesn’t appear at all, it may simply be hidden or off-screen. In that case, reopening the VBA editor or trying in a new workbook usually brings it back into view.

    The Trust Center and ActiveX settings generally affect whether controls can run, not whether you can edit their properties in the designer, so they’re unlikely to be the cause here.

    Hope this helps! If my answer was helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.

    0 comments No comments

  2. Senthil kumar 110 Reputation points
    2026-05-05T13:13:55.57+00:00

    Hi Alan Sears,

    Sheet Design

    • add controls then right click goto properties.
    • goto caption give your desired name.

    User's image

    User's image

    by User control:

    User's image

    User's image

    0 comments No comments

  3. Q&A Assist
    2026-05-05T12:50:58.2266667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    In Excel VBA, control properties are changed either in the Properties window at design time or via code at run time. If the Properties window is not appearing or not “useful,” check both how it is opened and what is selected.

    To open and use the Properties window for a UserForm control at design time:

    1. Open the Visual Basic Editor (VBE) from Excel (Developer tab → Visual Basic, or press ALT+F11).
    2. In the Project Explorer, double‑click the UserForm to open it in design mode.
    3. Click once on the CommandButton (or other control) on the UserForm so it is selected.
    4. Press F4, or on the VBE menu choose View → Properties Window.
    5. In the Properties window:
      • Confirm the Object box at the top shows the selected control (for example, CommandButton1). Only objects from the active form are visible.
      • Use the Alphabetic or Categorized tab to locate properties.
      • To rename the control (the name used in code), change the (Name) property.
      • To change the text shown on the button, change the Caption property.

    If multiple controls are selected, only properties common to all of them are shown. Ensure only the intended control is selected if some properties appear to be missing.

    If design‑time changes are not possible for some reason, the same properties can be set in code. For example, from the UserForm’s code module:

    Private Sub UserForm_Initialize()
        'Change the name used in code is done only in the Properties window, not here
        'Change the caption (text on the button) at run time
        Me.CommandButton1.Caption = "Run"
    End Sub
    

    For ActiveX controls placed directly on a worksheet (instead of on a UserForm):

    1. On the worksheet, turn on Developer → Controls → Design Mode.
    2. Click the ActiveX control (e.g., Command Button) to select it.
    3. On the Developer tab, in the Controls group, click Properties (or right‑click the control and choose Properties).
    4. In the Properties box, change (Name) to rename the control for use in code, and Caption to change the text on the button.

    At run time, the same worksheet ActiveX control can be manipulated via VBA, for example:

    Sheet1.CommandButton1.Caption = "Run"
    

    or via the OLEObjects collection:

    Worksheets(1).OLEObjects("CommandButton1").Object.Caption = "Run"
    

    If the Properties window still does not show anything useful, verify that:

    • A UserForm or control is actually selected (the Properties window is context‑sensitive).
    • The active window in the VBE is the UserForm designer, not just a code module.

    Once the correct object is selected and the Properties window is visible, all design‑time properties (including (Name) and Caption) can be edited directly there.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.