How to Show a Hidden VBA Menu Button When an Excel Workbook Opens
Question details
The user needs to automatically display a hidden VBA menu button or shape when a macro-enabled workbook is opened.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Extending the expiration dates in a macro-enabled workbook and needing the navigation menu or shape buttons to reappear automatically upon launching the file.
- Observed behavior
- The menu button remains hidden upon opening the workbook, even after the expiration dates in the VBA code have been updated to future dates.
Ensure that macros are fully enabled in your spreadsheet's Trust Center settings, and verify the exact name of both the target worksheet and the shape you intend to unhide.
Add Visibility Code to the Workbook_Open Event
Modify the VBA code triggered when the workbook opens to explicitly set the menu button's visibility property to true.
The most reliable way to ensure a specific button or shape is visible upon launching your file is to tie its Visible property to the Workbook_Open event. This overrides any previous hidden states saved when the file was last closed.
Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the Project Explorer pane on the left, locate your current workbook and double-click on 'ThisWorkbook'.
From the left dropdown at the top of the code window, select 'Workbook'. From the right dropdown, select 'Open'. This will generate the Private Sub Workbook_Open() block.
Inside the Workbook_Open subroutine, type the following code: Sheets("Instructions").Shapes("menuButton").Visible = True. Ensure you replace "Instructions" and "menuButton" with your actual sheet name and shape name.
Save the file immediately as a Macro-Enabled Workbook (.xlsm), close it, and reopen it to verify that the menu button appears as expected.

Use WPS Spreadsheet to Manage VBA and Macros Seamlessly
WPS Office provides robust support for VBA macros in its Spreadsheet application. You can easily edit Workbook_Open events, manage interactive shapes, and run automated scripts just like you do in Microsoft Excel.
- 1. Open Your Macro Workbook: Launch WPS Spreadsheet and open your existing .xlsm file.
- 2. Access the Developer Tools: Navigate to the 'Developer' tab on the top ribbon and click on 'VBA Editor'.
- 3. Edit the Workbook Event: Double-click 'ThisWorkbook' in the Project Explorer, insert your shape visibility code into the Workbook_Open event, and save the file.

Frequently Asked Questions
Why doesn't the Workbook_Open event trigger when I open the file?
This usually happens if macros are disabled by your security settings. Check your Trust Center or Macro Security settings to ensure macros are enabled, or look for a security warning bar below the ribbon and click 'Enable Content'.
How do I find the exact name of my shape or menu button?
Click on the shape in your worksheet, then look at the Name Box located immediately to the left of the formula bar. You can also rename the shape directly from this box by typing a new name and pressing Enter.
Can I hide the button again automatically when the workbook closes?
Yes. You can add the line Sheets("Instructions").Shapes("menuButton").Visible = False into the Private Sub Workbook_BeforeClose(Cancel As Boolean) event located in the 'ThisWorkbook' module.




