Upgraded to 2007 now hiding of Buttons not working the same

SSN651

New Member
Joined
Jun 22, 2010
Messages
6
There is a tab in my worksheet with over 20 buttons. They are hidden and unhidden by one control toggle button. In 2003 the control button, with a label of "Unprotect", executes to unprotect the worksheet and unhide all the other buttons. It then shifts its label to be "Protect". When the Protect button is executed, it hides all the other buttons and protects the worksheet and resets the label back to "Unprotect". At no time does the control button disappear. But in 2007, it is hidden and if I change the property of the button to be visible, it does appear. But as soon as I click it again, it disappears again until I edit its property again.

Can any one explian what the change is between 2003 to 2007 which is causing this irratating behaviour and how to fix it.

Below are the applicable code segments for the button:

Dim wksAgentKRIOAssessment As Worksheet
Dim objButton As OLEObject

Set wksAgentKRIOAssessment = ActiveSheet
'
If UnProtectProtect.Value = True Then
UnProtectProtect.Caption = "Protect"
... some stuff is executed ...

'Unhide Buttons
For Each objButton In wksAgentKRIOAssessment.OLEObjects
objButton.Visible = Not objButton.Visible
Next objButton
Else
UnProtectProtect.Caption = "UnProtect"
... some stuff is executed ...
'Hide Buttons
For Each objButton In wksAgentKRIOAssessment.OLEObjects
objButton.Visible = Not objButton.Visible
Next objButton
End If
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I'm surprised that it worked in 2003. Isn't your unprotectProtect button an OLE Object as weel as the other buttons?

So when the below code is executed, it switches all the buttons' visible attributes. When you hit your button to unhide the rest it will hide that button because its attribute was at true.

Code:
For Each objButton In wksAgentKRIOAssessment.OLEObjects
objButton.Visible = Not objButton.Visible
Next objButton

Maybe this will work
Code:
For Each objButton In wksAgentKRIOAssessment.OLEObjects
if objButton.name <> "UnProtectProtect"  then  objButton.Visible = Not objButton.Visible
Next objButton
 
Upvote 0
:) AH Great minds think alike. I just completed testing of such a change, to question the object name and if it is the one I want to not change its visibility to exit out of the For statement.

Just to make sure I wasn't crazy, I went back to a computer still running 2003. It still runs just like I said. I did get started on the idea about testing for the object's name by creating a new toggle button. The only thing was, that a toggle button seems to only be available under the Active X controls. When I created that type of button, it did not disappear. While doing some research on the web for related information, I came across an MSN site for Microsoft Office ... Name space information, http://msdn.microsoft.com/en-us/library/7fzyhc74(v=VS.80).aspx. I used serveral of the properties listed there to try to figure what was happening. When I tested the Name property, that is when I got the inisight to try the test for the name of the button I wanted kept visible all the time.

Thank you for your suggestion, good to know that there is not a "system" solution, i.e. set some parameter somewhere and all will be as it was before.

John
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,692
Members
449,117
Latest member
Aaagu

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