Hiding and Revealing Shapes in VBA

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have three shapes with macro's assigned to them that I use as buttons. (I can't recall why at the top of my head, but they provided better functionality than userform buttons.)
I'm in a position now, that I require these buttons to be hidden until a certian code is encountered to reveal them.

What is the best way of going about doing this? Similarly, is there a way to disable macros from a shape in VBA?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You can set the Shapes' Visible property to True/False. What is the condition that determines their visibility?
 
Upvote 0
Hi Andrew ...

It will be a simple If / Then condition. If the value in B14 = yes, then reveal the series of three shapes (Buttons). When these three buttons are revealed, I'd like to disable the macro's of two other similar "button" shapes on the worksheet.

I'm not sure though where to get the shape's name to set the property. (these are drawn shapes found in the "Illustrations" section of the "Insert" ribbon) I'm assuming your referring to a code like shape1.visible=true ? But I don't know where to find the "shape1" reference.
 
Upvote 0
The shape names will appear in the Name box to the left of the formula bar.

You can also change their name(s) there.
 
Upvote 0
Hi Norie ....
Thanks ... something new! I see the names have spaces in them (Rounded Rectangle 10). Is this how I would refer to it in VBA, with the spaces?
I tried to change the names, but when I wen't back to them, they were back to the original name.
 
Last edited:
Upvote 0
OK. Got it.
Is it possible to disable a macro from a shape without using enableevents?
 
Upvote 0
OK ... problems.
Code:
With wshmain
     btnexit.visible=false
end with

Results in an 'object required' error.

The shape is on the page and visible, worksheet is unprotected.
 
Upvote 0
OK ... problems.
Code:
With wshmain
     btnexit.visible=false
end with

Results in an 'object required' error.

The shape is on the page and visible, worksheet is unprotected.
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top