Show or hide components

Updated at:

Sets the Visible property on a CommandBars object to show or hide a specific UI component.

  • Demonstration

    • Hide the component Hide

    • Show the component Show

  • Syntax

    expression.CommandBars(CommandBarId).Visible

    expression: the document type application object. Visible is a read/write Boolean property. Reading the value requires await because the SDK call is asynchronous.

  • Example

    The following example hides the More Menus button, then reads back the Visible value to confirm the change.

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Get the More Menus button.
      const moreMenus = await app.CommandBars('MoreMenus');
    
      // Hide the More Menus button.
      moreMenus.Visible = false;
    
      // Read back the Visible value (returns a Boolean).
      const visible = await moreMenus.Visible;
      console.log(visible); // false
    }